示例#1
0
        /// <summary>
        /// DataSet输出XML格式文档
        /// </summary>
        /// <param name="filepath">XML文件路径</param>
        public static void WriteDataSetToXml(string filepath)
        {
            DataSet ds = new DataSet();

            EKFile.GetMapPath(filepath);
            //创建XML对象
            XmlTextWriter xml = new XmlTextWriter(filepath, Encoding.Default);

            try
            {
                //设置返回格式
                xml.Formatting  = Formatting.Indented;
                xml.Indentation = 4;//缩进
                xml.IndentChar  = ' ';
                xml.WriteStartDocument();
                //输出XML格式数据 到客户端
                ds.WriteXml(xml);
            }
            catch
            {
            }
            finally
            {
                xml.Flush();
                xml.Close();
            }
        }
示例#2
0
 /// <summary>
 /// 打开数据库
 /// </summary>
 private static void openConnection()
 {
     if (conn.State == ConnectionState.Closed)
     {
         string conStr = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + EKFile.GetMapPath("/") + ConnectString + ";";
         if (Password == "")
         {
             conStr += "Persist Security Info=False;";
         }
         else
         {
             conStr += "Jet OLEDB:Database PassWord="******"";
         }
         conn.ConnectionString = conStr;
         comm.Connection       = conn;
         try
         {
             conn.Open();
         }
         catch (Exception e)
         { throw new Exception(e.Message); }
     }
 }