當前位置: 首頁>>代碼示例>>C#>>正文


C# DataTable.ReadXml方法代碼示例

本文整理匯總了C#中System.Data.DataTable.ReadXml方法的典型用法代碼示例。如果您正苦於以下問題:C# DataTable.ReadXml方法的具體用法?C# DataTable.ReadXml怎麽用?C# DataTable.ReadXml使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Data.DataTable的用法示例。


在下文中一共展示了DataTable.ReadXml方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: UpdateFile

        public void UpdateFile()
        {
            DataTable table = new DataTable();
            table.ReadXml(fileName);

            KillLanMsgProcess();
            Thread.Sleep(2000);
            //�����ļ�

            StringBuilder strbuilder = new StringBuilder();
            string filepath = string.Empty;
            foreach (DataRow row in table.Rows) {
                filepath = row["filepath"].ToString();
                if (filepath.ToLower().LastIndexOf("Itop.update.copy") >= 0) continue;
                string updatefile = Application.StartupPath + "\\update\\" + filepath;
                string appfile = Application.StartupPath + filepath;
                labFile.Text = filepath;
                Application.DoEvents();
                File.Copy(updatefile, appfile, true);
                strbuilder.AppendLine(filepath);
            }
            MessageBox.Show("�������!", "����");

            //���������ϵͳ

            System.Diagnostics.Process.Start("Itop.exe");
            Application.Exit();
        }
開發者ID:EdgarEDT,項目名稱:myitoppsp,代碼行數:28,代碼來源:Form1.cs

示例2: Form2_Load

        private void Form2_Load(object sender, EventArgs e)
        {
            dt = new DataTable("saz","sazconfig");
            dt.Columns.Add("sx");
            dt.Columns.Add("sy");
            dt.Columns.Add("sw");
            dt.Columns.Add("sh");
            dt.Columns.Add("dx");
            dt.Columns.Add("dy");
            dt.Columns.Add("dw");
            dt.Columns.Add("dh");
            try
            {
                dt.ReadXml("saz.xml");
            }
            catch (Exception err) { }

            dataGridView1.DataSource = dt;

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                new Form1(
                    Convert.ToInt32(dt.Rows[i]["sx"]),
                    Convert.ToInt32(dt.Rows[i]["sy"]),
                    Convert.ToInt32(dt.Rows[i]["sw"]),
                    Convert.ToInt32(dt.Rows[i]["sh"]),
                    Convert.ToInt32(dt.Rows[i]["dx"]),
                    Convert.ToInt32(dt.Rows[i]["dy"]),
                    Convert.ToInt32(dt.Rows[i]["dw"]),
                    Convert.ToInt32(dt.Rows[i]["dh"])
                    ).Show();
            }
            //new Form1().Show();
        }
開發者ID:blamarche,項目名稱:screen-area-zoomer,代碼行數:34,代碼來源:Form2.cs

示例3: frmCauHinhCSDL

        public frmCauHinhCSDL()
        {
            InitializeComponent();

            var dt = new DataTable("CauHinhCSDL");
            dt.Columns.Add("MayChu");
            dt.Columns.Add("TaiKhoanSQL");
            dt.Columns.Add("Password");
            dt.Columns.Add("CSDL");

            var fi = new FileInfo(Application.StartupPath + "\\CauHinhCSDL.xml");
            if (!fi.Exists) return;

            dt.ReadXml(Application.StartupPath + "\\CauHinhCSDL.xml");
            try
            {
                if (dt.Rows.Count > 0)
                {
                    txtMayChuSQL.Text = dt.Rows[0]["MayChu"].ToString();
                    txtTaiKhoanSQL.Text = dt.Rows[0]["TaiKhoanSQL"].ToString();
                    txtPassword.Text = dt.Rows[0]["Password"].ToString();
                    txtTenCSDL.Text = dt.Rows[0]["CSDL"].ToString();
                }
            }
            catch (Exception ex)
            {
            }
        }
開發者ID:gojila,項目名稱:Quan_Ly_Kinh_Doanh,代碼行數:28,代碼來源:frmCauHinhCSDL.cs

示例4: Initialize

		private void Initialize()
		{
			string dataSourceCfgPath = System.Configuration.ConfigurationSettings.AppSettings["DataSourceCfg"];

			try
			{
				DataColumn alias = new DataColumn("Alias");
				DataColumn dsn = new DataColumn("Dsn");
				DataColumn uid = new DataColumn("Uid");
				DataColumn pwd = new DataColumn("Pwd");

				_tbDataSource = new DataTable("DataSource");
				
				_tbDataSource.Columns.Add(alias);
				_tbDataSource.Columns.Add(dsn);
				_tbDataSource.Columns.Add(uid);
				_tbDataSource.Columns.Add(pwd);
				
				_tbDataSource.ReadXml(dataSourceCfgPath);
				
				_bsDataSource = new BindingSource();
				_bsDataSource.DataSource = _tbDataSource;
				
				Console.Out.WriteLine("Load DataSource Success!");
			}
			catch(Exception ex)
			{
				Console.Out.WriteLine("Load DataSource Success! " + ex.Message);
				//MessageBox.Show("Loading DataSource failure! " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
			}
		}
開發者ID:garryforreg,項目名稱:iview-scada,代碼行數:31,代碼來源:DataSourceManager.cs

示例5: button1_Click

        private void button1_Click(object sender, EventArgs e)
        {
            string appdir = Path.GetDirectoryName(Application.ExecutablePath);

            DataTable dtin = new DataTable();
            dtin.ReadXml(Path.Combine(appdir, "f3.xml"));
        }
開發者ID:gopa810,項目名稱:StreamChangerA,代碼行數:7,代碼來源:Form1.cs

示例6: Main_Load

 private void Main_Load(object sender, EventArgs e)
 {
     DataTable _table = new DataTable();
     _table.ReadXml(Application.StartupPath + @"\Data\Books.xml");
     metroGrid1.DataSource = _table;
     metroGrid1.AutoSizeCols();   
 }
開發者ID:BruceHao,項目名稱:datagridview-metroframework,代碼行數:7,代碼來源:Main.cs

示例7: Backup_Load

        /// <summary>
        /// initialize Backup
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void Backup_Load(object sender, EventArgs e)
        {
            var culture = new CultureInfo(CfgFile.Get("Lang"));
            SetCulture(culture);

            restobj = new Restore();
            var myTable = new DataTable("dataTable");
            myTable.Columns.Add(rm.GetString("name"), typeof (string));
            myTable.Columns.Add(rm.GetString("path"), typeof (string));
            myTable.Columns.Add("Date", typeof (DateTime));
            myTable.Columns.Add(rm.GetString("sel"), typeof (bool));

            myTable.ReadXmlSchema(@"schemefile");
            myTable.ReadXml(@"datafile");
            string str = null;

            for (int i = 0; i < myTable.Rows.Count; i++)
            {
                string item = Convert.ToString(myTable.Rows[i][2]);
                if (str != item)
                {
                    lsbMain.Items.Add(item);
                    str = item;
                }
            }
        }
開發者ID:nullkuhl,項目名稱:fsu-dev,代碼行數:31,代碼來源:BackupForm.cs

示例8: GetResults

        public ModuleResults GetResults(InstanceInfo instanceInfo)
        {
            try
            {
                ProbeHelper.InstallProbe(instanceInfo.Directory);

                var uri = new Uri(instanceInfo.Uri, "CMSPages/KInspectorProbe.aspx");
                HttpWebRequest request = WebRequest.CreateHttp(uri);
                using (WebResponse response = request.GetResponse())
                {
                    DataTable result = new DataTable();
                    result.ReadXml(response.GetResponseStream());

                    return new ModuleResults
                    {
                        Result = result,
                    };
                }
            }
            catch (Exception e)
            {
                // Probably 404
                return new ModuleResults
                {
                    Result = e.ToString(),
                    Status = Status.Error
                };
            }
            finally
            {
                ProbeHelper.UninstallProbe(instanceInfo.Directory);
            }
        }
開發者ID:oravecjakub,項目名稱:KInspector,代碼行數:33,代碼來源:CacheItemsModule.cs

示例9: Create

        private DataTable Create()
        {
            string dataSchemaPath = Directory.GetCurrentDirectory() + "\\" + dataSchemaName + ".xml";
            string dataPath = Directory.GetCurrentDirectory() + "\\" + dataFileName + ".xml";

            DataTable dt = new DataTable();

            if (File.Exists(dataPath))
            {
                dt.ReadXmlSchema(dataSchemaPath);
                dt.ReadXml(dataPath);
            }
            else
            {
                dt.Columns.Add("VaultName", typeof(string));
                dt.Columns.Add("ArchiveId", typeof(string));
                dt.Columns.Add("ZipName", typeof(string));
                dt.Columns.Add("FilePath", typeof(string));
                dt.Columns.Add("EnterdDate", typeof(DateTime));

                dt.TableName = dataFileName;
                dt.PrimaryKey = new[] { dt.Columns["VaultName"], dt.Columns["ArchiveId"], dt.Columns["FilePath"] };
            }

            return dt;
        }
開發者ID:jacoyutorius,項目名稱:IcePickle,代碼行數:26,代碼來源:Data.cs

示例10: LoadDataTable

 /// <summary>
 /// 從 XML 文件中讀取數據,形成 DataTable.
 /// 
 /// 參考 A0150_Access 項目的 ReadAccessDB.cs
 /// </summary>
 /// <returns></returns>
 private static DataTable LoadDataTable()
 {
     DataTable newDt = new DataTable();
     newDt.ReadXmlSchema(DATATABLE_SCHEMA_XML_FILE);
     newDt.ReadXml(DATATABLE_XML_FILE);
     return newDt;
 }
開發者ID:mahuidong,項目名稱:my-csharp-sample,代碼行數:13,代碼來源:LinqDataSetSample.cs

示例11: initCheckPlugin

        public void initCheckPlugin(int instance, addTextCP callback, string configDir)
        {
            this.addTextCB = callback;
            this.Instance = instance;
            this.confDir = configDir;

            try {
                 // Create Settings Table
                DataTable mySettings = new DataTable("SettingsPluginCheckNet");
                mySettings.ReadXml(confDir + Path.DirectorySeparatorChar + "config_plugin_checknet.xml");

                optStrServerAddress = mySettings.Rows[instance]["ServerAddress"].ToString();
                optPort = Convert.ToInt32(mySettings.Rows[instance]["Port"].ToString(), 10);
                optStrMode = mySettings.Rows[instance]["Mode"].ToString();
                optTimeout = Convert.ToInt32(mySettings.Rows[instance]["Timeout"].ToString(), 10);
                optStrCheck = mySettings.Rows[instance]["CheckStr"].ToString();
                optStrSendBeforeCheck = mySettings.Rows[instance]["SendBeforeCheckStr"].ToString();
            }
            catch {
                // loading failed -> go to defaults
                optStrCheck = "";
                optStrMode  = "TCP";
                optStrSendBeforeCheck  = "";
                optStrServerAddress = "127.0.0.1";
                optTimeout = 1000;
                optPort = 80;
            }
        }
開發者ID:paperwork,項目名稱:sourceremotecontrol,代碼行數:28,代碼來源:PluginCheckNet.cs

示例12: btnImport_Click

        private void btnImport_Click(object sender, EventArgs e)
        {
            if (openFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                string filename = openFileDialog.FileName;
                string extension = Path.GetExtension(filename);
                if (extension == ".xls" || extension == ".xlsx")
                {
                    Excel db = new Excel(filename, true, false);
                    TableSelectDialog t = new TableSelectDialog(db.GetWorksheetList());

                    if (t.ShowDialog(this) == DialogResult.OK)
                    {
                        this.TableDataSource.Import(db.GetWorksheet(t.Selection));
                    }
                }
                else if (extension == ".xml")
                {
                    DataTable dataTableAnalysisSource = new DataTable();
                    dataTableAnalysisSource.ReadXml(openFileDialog.FileName);

                    this.TableDataSource.Import(dataTableAnalysisSource);
                }
            }
        }
開發者ID:pirzada,項目名稱:sinapse,代碼行數:25,代碼來源:TableSourceView.cs

示例13: ImportTableWithoutBulkCopy

        public ReturnValue ImportTableWithoutBulkCopy(string path)
        {
            return ReturnValue.Wrap(() =>
            {
                PreprareConnection();
                var dt = new DataTable();
                dt.ReadXml(path);

                using (SqlTransaction tran = Connection.BeginTransaction(IsolationLevel.Serializable))
                {
                    Connection.ExecSql(string.Format("DELETE  {0}", dt.TableName), tran);
                    string sql = string.Format("SELECT * FROM {0}", dt.TableName);
                    var cmd = new SqlCommand(sql, Connection, tran);
                    var ds = new DataSet();
                    ds.EnforceConstraints = false;
                    ds.Tables.Add(dt);
                    var dataAdapter = new SqlDataAdapter(cmd);
                    // Automatically generates DeleteCommand, UpdateCommand and InsertCommand for DataAdapter object 
                    var builder = new SqlCommandBuilder(dataAdapter);
                    dataAdapter.Update(dt);
                    tran.Commit();
                    ds.Tables.Remove(dt);
                }
            }, string.Format("Importing table from {0}.", path));
        }
開發者ID:ninerats,項目名稱:DataTools,代碼行數:25,代碼來源:DataTableSerializer.cs

示例14: FillGridOld

		/// <summary></summary>
		private void FillGridOld() {
			List<WikiListHeaderWidth> colHeaderWidths=WikiListHeaderWidths.GetFromListHist(_listWikiListHists[gridMain.GetSelectedIndex()]);
			_tableOld=new DataTable();
			using(XmlReader xmlReader=XmlReader.Create(new StringReader(_listWikiListHists[gridMain.GetSelectedIndex()].ListContent))) {
				_tableOld.ReadXml(xmlReader);
			}
			gridOld.BeginUpdate();
			gridOld.Columns.Clear();
			ODGridColumn col;
			for(int c=0;c<_tableOld.Columns.Count;c++) {
				int colWidth=100;//100 = default value in case something is malformed in the database.
				foreach(WikiListHeaderWidth colHead in colHeaderWidths) {
					if(colHead.ColName==_tableOld.Columns[c].ColumnName) {
						colWidth=colHead.ColWidth;
						break;
					}
				}
				col=new ODGridColumn(_tableOld.Columns[c].ColumnName,colWidth,false);
				gridOld.Columns.Add(col);
			}
			gridOld.Rows.Clear();
			ODGridRow row;
			for(int i=0;i<_tableOld.Rows.Count;i++) {
				row=new ODGridRow();
				for(int c=0;c<_tableOld.Columns.Count;c++) {
					row.Cells.Add(_tableOld.Rows[i][c].ToString());
				}
				gridOld.Rows.Add(row);
				gridOld.Rows[i].Tag=i;
			}
			gridOld.EndUpdate();
		}
開發者ID:mnisl,項目名稱:OD,代碼行數:33,代碼來源:FormWikiListHistory.cs

示例15: initCheckPlugin

        public void initCheckPlugin(int instance, addTextCP callback, string configDir)
        {
            addTextCB = callback;
            this.inst = instance;
            confDir = configDir;

            try
            {
                 // Create Settings Table
                DataTable mySettings = new DataTable("SettingsPluginCheckSerial");
                mySettings.ReadXml(confDir + Path.DirectorySeparatorChar + "config_plugin_checkserial.xml");

                optSerialPort = mySettings.Rows[instance]["ComPort"].ToString();
                optBaudrate = Convert.ToInt32(mySettings.Rows[instance]["Baudrate"].ToString(), 10);
                optDataBitIndex = Convert.ToInt32(mySettings.Rows[instance]["DataBits"].ToString(), 10);
                optHandshakeIndex = Convert.ToInt32(mySettings.Rows[instance]["Handshake"].ToString(), 10);
                optParityIndex = Convert.ToInt32(mySettings.Rows[instance]["Parity"].ToString(), 10);
                optReadTimeout = Convert.ToInt32(mySettings.Rows[instance]["ReadTimeout"].ToString(), 10);
                optStopBitsIndex = Convert.ToInt32(mySettings.Rows[instance]["StopBits"].ToString(), 10);
                optStrCheck = mySettings.Rows[instance]["CheckStr"].ToString();
                optStrSendBeforeCheck = mySettings.Rows[instance]["SendBeforeCheckStr"].ToString();
            }
            catch
            {
                optSerialPort = "COM1";
                optBaudrate = 57600;
                optDataBitIndex = 3;
                optParityIndex = 0;
                optStopBitsIndex = 0;
                optHandshakeIndex = 0;
                optReadTimeout = 500;
            }
        }
開發者ID:paperwork,項目名稱:sourceremotecontrol,代碼行數:33,代碼來源:PluginCheckSerial.cs


注:本文中的System.Data.DataTable.ReadXml方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。