当前位置: 首页>>代码示例>>C#>>正文


C# DataTable.ReadXmlSchema方法代码示例

本文整理汇总了C#中System.Data.DataTable.ReadXmlSchema方法的典型用法代码示例。如果您正苦于以下问题:C# DataTable.ReadXmlSchema方法的具体用法?C# DataTable.ReadXmlSchema怎么用?C# DataTable.ReadXmlSchema使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Data.DataTable的用法示例。


在下文中一共展示了DataTable.ReadXmlSchema方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: ReadToDataTable

        public DataTable ReadToDataTable()
        {
            DataTable dt = new DataTable(System.IO.Path.GetFileNameWithoutExtension(FileName));
            dt.ReadXmlSchema(this.FileName);
            dt.ReadXml(FileName);

            return dt;
        }
开发者ID:hy1314200,项目名称:HyDM,代码行数:8,代码来源:XmlConfigReader.cs

示例5: ConvertXMLToDataTable

 public DataTable ConvertXMLToDataTable(string xml)
 {
     System.IO.TextReader trDataTable = new System.IO.StringReader(xml.Substring(0, xml.IndexOf("<?xml")));
     System.IO.TextReader trSchema = new System.IO.StringReader(xml.Substring(xml.IndexOf("<?xml")));
     DataTable dtReturn = new DataTable();
     dtReturn.ReadXmlSchema(trSchema);
     dtReturn.ReadXml(trDataTable);
     return dtReturn;
 }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:9,代码来源:INVCommon.cs

示例6: ServerForm

        public ServerForm()
        {
            this._iconList = new List<PictureBox>();
            this._labelList = new List<Label>();
            for (int i = 0; i < 8; i++)
            {
                PictureBox newbox = new PictureBox();
                Point point = new Point((81 + 72*i), 254);
                newbox.Location = point;
                newbox.ImageLocation = Environment.CurrentDirectory + "/../../Resources/buddy_bleu_normal.png";
                newbox.SizeMode = PictureBoxSizeMode.AutoSize;
                newbox.Visible = false;
                this.Controls.Add(newbox);
                _iconList.Add(newbox);

                Label newlabel = new Label();
                newlabel.Font = new Font("Impact", 15);
                newlabel.Visible = false;
                //newlabel.TextAlign = ContentAlignment.MiddleCenter;
                newlabel.Text = "-1";
                newlabel.BackColor = Color.Transparent;
                //newlabel.Location = point;
                newlabel.Parent = _iconList[i];
                _labelList.Add(newlabel);
            }

            Panel panel = new Panel();
            panel.BorderStyle = BorderStyle.FixedSingle;
            panel.Visible = true;
            panel.BackColor = Color.White;
            panel.Location = new Point(66, 311);
            panel.Size = new Size(600, 128);
            this.Controls.Add(panel);
            panel.BringToFront();

            //this._dataObj = new DataPack();

            InitializeComponent();

            DataTable table = new DataTable();
            string schemePath = Environment.CurrentDirectory + "/../../TableScheme.xsd";
            table.ReadXmlSchema(schemePath);

            DataPack._cli_table = table;

            setData();

            this._server = new ServerListener(9000);
            _srv_thread = new Thread(this._server.RegisterClients);
            _srv_thread.Start();
        }
开发者ID:walzero,项目名称:TrabalhoFilosofos,代码行数:51,代码来源:ServerForm.cs

示例7: Get

        public DataTable Get()
        {
            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 = Create();
            }

            return dt;
        }
开发者ID:jacoyutorius,项目名称:IcePickle,代码行数:19,代码来源:Data.cs

示例8: XmlSchemaTest7

		public void XmlSchemaTest7 ()
		{
			DataTable table = new DataTable ();
			
			try {
				table.ReadXmlSchema (string.Empty);
				Assert.Fail ("#1");
			} catch (ArgumentException ex) {
				// The URL cannot be empty
				Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
				Assert.IsNull (ex.InnerException, "#3");
				Assert.IsNotNull (ex.Message, "#4");
				//Assert.AreEqual ("url", ex.ParamName, "#5");
			}
		}
开发者ID:nlhepler,项目名称:mono,代码行数:15,代码来源:DataTableTest3.cs

示例9: XmlSchemaTest5

		public void XmlSchemaTest5 ()
		{
			MakeParentTable ();
			MakeChildTable ();
			MakeSecondChildTable ();
			MakeDataRelation ();
			
			//Write
			using (FileStream stream = new FileStream (tempFile, FileMode.Create)) {
				childTable.WriteXmlSchema (stream);
			}

			//Read
			DataTable table = new DataTable (childTable.TableName);
			using (FileStream stream = new FileStream (tempFile, FileMode.Open)) {
				table.ReadXmlSchema (stream);
			}
			
			//Check Properties of the table
			Assert.AreEqual (string.Empty, table.Namespace, "#1");
			Assert.IsNull (table.DataSet, "#2");
			Assert.AreEqual (3, table.Columns.Count, "#3");
			Assert.AreEqual (0, table.Rows.Count, "#4");
			Assert.AreEqual (false, table.CaseSensitive, "#5");
			Assert.AreEqual ("ChildTable", table.TableName, "#6");
			Assert.AreEqual (string.Empty, table.Prefix, "#7");
			Assert.AreEqual (1, table.Constraints.Count, "#8");
			Assert.AreEqual ("Constraint1", table.Constraints [0].ToString (), "#9");
			Assert.AreEqual (typeof (UniqueConstraint), table.Constraints [0].GetType(), "#10");
			Assert.AreEqual (0, table.ParentRelations.Count, "#11");
			Assert.AreEqual (0, table.ChildRelations.Count, "#12");
			Assert.AreEqual (0, table.PrimaryKey.Length, "#13");
			
			//First Column
			DataColumn col = table.Columns [0];
			Assert.AreEqual (true, col.AllowDBNull, "#14");
			Assert.AreEqual (true, col.AutoIncrement, "#15");
			Assert.AreEqual (0, col.AutoIncrementSeed, "#16");
			Assert.AreEqual (1, col.AutoIncrementStep, "#17");
			Assert.AreEqual ("Element", col.ColumnMapping.ToString (), "#18");
			Assert.AreEqual ("ChildID", col.ColumnName, "#19");
			Assert.AreEqual (typeof (int), col.DataType, "#20");
			Assert.AreEqual (string.Empty, col.DefaultValue.ToString (), "#21");
			Assert.AreEqual (false, col.DesignMode, "#22");
			Assert.AreEqual ("System.Data.PropertyCollection", col.ExtendedProperties.ToString (), "#23");
			Assert.AreEqual (-1, col.MaxLength, "#24");
			Assert.AreEqual (0, col.Ordinal, "#25");
			Assert.AreEqual (string.Empty, col.Prefix, "#26");
			Assert.AreEqual ("ChildTable", col.Table.ToString (), "#27");
			Assert.AreEqual (true, col.Unique, "#28");

			//Second Column
			col = table.Columns [1];
			Assert.AreEqual (true, col.AllowDBNull, "#29");
			Assert.AreEqual (false, col.AutoIncrement, "#30");
			Assert.AreEqual (0, col.AutoIncrementSeed, "#31");
			Assert.AreEqual (1, col.AutoIncrementStep, "#32");
			Assert.AreEqual ("Element", col.ColumnMapping.ToString (), "#33");
			Assert.AreEqual ("ChildItem", col.Caption, "#34");
			Assert.AreEqual ("ChildItem", col.ColumnName, "#35");
			Assert.AreEqual (typeof (string), col.DataType, "#36");
			Assert.AreEqual (string.Empty, col.DefaultValue.ToString (), "#37");
			Assert.AreEqual (false, col.DesignMode, "#38");
			Assert.AreEqual ("System.Data.PropertyCollection", col.ExtendedProperties.ToString (), "#39");
			Assert.AreEqual (-1, col.MaxLength, "#40");
			Assert.AreEqual (1, col.Ordinal, "#41");
			Assert.AreEqual (string.Empty, col.Prefix, "#42");
			Assert.AreEqual ("ChildTable", col.Table.ToString (), "#42");
			Assert.AreEqual (false, col.Unique, "#43");

			//Third Column
			col = table.Columns [2];
			Assert.AreEqual (true, col.AllowDBNull, "#44");
			Assert.AreEqual (false, col.AutoIncrement, "#45");
			Assert.AreEqual (0, col.AutoIncrementSeed, "#46");
			Assert.AreEqual (1, col.AutoIncrementStep, "#47");
			Assert.AreEqual ("Element", col.ColumnMapping.ToString (), "#48");
			Assert.AreEqual ("ParentID", col.Caption, "#49");
			Assert.AreEqual ("ParentID", col.ColumnName, "#50");
			Assert.AreEqual (typeof (int), col.DataType, "#51");
			Assert.AreEqual (string.Empty, col.DefaultValue.ToString (), "#52");
			Assert.AreEqual (false, col.DesignMode, "#53");
			Assert.AreEqual ("System.Data.PropertyCollection", col.ExtendedProperties.ToString (), "#54");
			Assert.AreEqual (-1, col.MaxLength, "#55");
			Assert.AreEqual (2, col.Ordinal, "#56");
			Assert.AreEqual (string.Empty, col.Prefix, "#57");
			Assert.AreEqual ("ChildTable", col.Table.ToString (), "#58");
			Assert.AreEqual (false, col.Unique, "#59");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:89,代码来源:DataTableTest3.cs

示例10: XmlSchemaTest3

		public void XmlSchemaTest3 ()
		{
			//Write
			MakeParentTable ();

			using (FileStream stream = new FileStream (tempFile, FileMode.Create)) {
				parentTable.WriteXmlSchema (stream);
			}

			//Read
			DataTable table = new DataTable ();
			using (FileStream stream = new FileStream (tempFile, FileMode.Open)) {
				table.ReadXmlSchema (stream);
			}

			VerifyTableSchema (table, parentTable.TableName, null);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:17,代码来源:DataTableTest3.cs

示例11: ReadWriteXmlSchemaExp_TableNameConflict

		public void ReadWriteXmlSchemaExp_TableNameConflict ()
		{
			DataTable dtw = new DataTable ("Table1");
			StringWriter writer1 = new StringWriter ();
			dtw.WriteXmlSchema (writer1);
			DataTable dtr = new DataTable ("Table2");
			StringReader reader1 = new StringReader (writer1.ToString());
			try {
				dtr.ReadXmlSchema (reader1);
				Assert.Fail ("#1");
			} catch (ArgumentException) {
			}
		}
开发者ID:symform,项目名称:mono,代码行数:13,代码来源:DataTableTest.cs

示例12: WriteXmlSchema_Relations_ForeignKeys

		public void WriteXmlSchema_Relations_ForeignKeys ()
		{
			MemoryStream ms1 = null;
			MemoryStream ms2 = null;
			MemoryStream msA = null;
			MemoryStream msB = null;

			DataSet ds1 = new DataSet ();

			DataTable table1 = ds1.Tables.Add ("Table 1");
			DataTable table2 = ds1.Tables.Add ("Table 2");

			DataColumn col1_1 = table1.Columns.Add ("col 1", typeof (int));
			DataColumn col1_2 = table1.Columns.Add ("col 2", typeof (int));
			DataColumn col1_3 = table1.Columns.Add ("col 3", typeof (int));
			DataColumn col1_4 = table1.Columns.Add ("col 4", typeof (int));
			DataColumn col1_5 = table1.Columns.Add ("col 5", typeof (int));
			DataColumn col1_6 = table1.Columns.Add ("col 6", typeof (int));
			DataColumn col1_7 = table1.Columns.Add ("col 7", typeof (int));

			DataColumn col2_1 = table2.Columns.Add ("col 1", typeof (int));
			DataColumn col2_2 = table2.Columns.Add ("col 2", typeof (int));
			DataColumn col2_3 = table2.Columns.Add ("col 3", typeof (int));
			DataColumn col2_4 = table2.Columns.Add ("col 4", typeof (int));
			DataColumn col2_5 = table2.Columns.Add ("col 5", typeof (int));
			DataColumn col2_6 = table2.Columns.Add ("col 6", typeof (int));
			DataColumn col2_7 = table2.Columns.Add ("col 7", typeof (int));

			ds1.Relations.Add ("rel 1",
				new DataColumn[] { col1_1, col1_2 },
				new DataColumn[] { col2_1, col2_2 },
				false);
			ds1.Relations.Add ("rel 2",
				new DataColumn[] { col1_3, col1_4 },
				new DataColumn[] { col2_3, col2_4 },
				true);
			table2.Constraints.Add ("fk 1",
				new DataColumn[] { col1_5, col1_6 },
				new DataColumn[] { col2_5, col2_6 });
			table1.Constraints.Add ("fk 2",
				new DataColumn[] { col2_5, col2_6 },
				new DataColumn[] { col1_5, col1_6 });

			table1.Constraints.Add ("pk 1", col1_7, true);
			table2.Constraints.Add ("pk 2", col2_7, true);

			ms1 = new MemoryStream ();
			ds1.Tables[0].WriteXmlSchema (ms1);
			ms2 = new MemoryStream ();
			ds1.Tables[1].WriteXmlSchema (ms2);

			msA = new MemoryStream (ms1.GetBuffer ());
			DataTable dtA = new DataTable ();
			dtA.ReadXmlSchema (msA);

			msB = new MemoryStream (ms2.GetBuffer ());
			DataTable dtB = new DataTable ();
			dtB.ReadXmlSchema (msB);

			Assert.AreEqual (3, dtA.Constraints.Count, "#2");
			Assert.AreEqual (2, dtB.Constraints.Count, "#3");

			Assert.IsTrue (dtA.Constraints.Contains ("pk 1"), "#5");
			Assert.IsTrue (dtA.Constraints.Contains ("Constraint1"), "#6");
			Assert.IsTrue (dtA.Constraints.Contains ("Constraint2"), "#7");
			Assert.IsTrue (dtB.Constraints.Contains ("pk 2"), "#9");
			Assert.IsTrue (dtB.Constraints.Contains ("Constraint1"), "#10");
		}
开发者ID:symform,项目名称:mono,代码行数:68,代码来源:DataTableTest.cs

示例13: ReadXmlSchema_ByTextReader

		public void ReadXmlSchema_ByTextReader ()
		{
			DataSet ds1 = new DataSet ();
			ds1.Tables.Add (DataProvider.CreateParentDataTable ());
			ds1.Tables.Add (DataProvider.CreateChildDataTable ());

			StringWriter sw1 = new StringWriter ();
			StringWriter sw2 = new StringWriter ();
			//write xml file, schema only
			//ds1.WriteXmlSchema (sw);
			ds1.Tables[0].WriteXmlSchema (sw1);
			ds1.Tables[1].WriteXmlSchema (sw2);

			StringReader sr1 = new StringReader (sw1.GetStringBuilder ().ToString ());
			StringReader sr2 = new StringReader (sw2.GetStringBuilder ().ToString ());
			//copy both data and schema
			//DataSet ds2 = new DataSet ();
			DataTable dt1 = new DataTable ();
			DataTable dt2 = new DataTable ();

			//ds2.ReadXmlSchema (sr);
			dt1.ReadXmlSchema (sr1);
			dt2.ReadXmlSchema (sr2);

			//check xml schema
			// ReadXmlSchema - Tables count
			//Assert.AreEqual (ds2.Tables.Count, ds1.Tables.Count, "DS283");

			// ReadXmlSchema - Tables 0 Col count
			Assert.AreEqual (ds1.Tables[0].Columns.Count, dt1.Columns.Count, "DS284");

			// ReadXmlSchema - Tables 1 Col count
			Assert.AreEqual (ds1.Tables[1].Columns.Count, dt2.Columns.Count, "DS285");

			//check some colummns types
			// ReadXmlSchema - Tables 0 Col type
			Assert.AreEqual (ds1.Tables[0].Columns[0].GetType (), dt1.Columns[0].GetType (), "DS286");

			// ReadXmlSchema - Tables 1 Col type
			Assert.AreEqual (ds1.Tables[1].Columns[3].GetType (), dt2.Columns[3].GetType (), "DS287");

			//check that no data exists
			// ReadXmlSchema - Table 1 row count
			Assert.AreEqual (0, dt1.Rows.Count, "DS288");

			// ReadXmlSchema - Table 2 row count
			Assert.AreEqual (0, dt2.Rows.Count, "DS289");
		}
开发者ID:symform,项目名称:mono,代码行数:48,代码来源:DataTableTest.cs

示例14: dlgOpenFile_FileOk

        private void dlgOpenFile_FileOk(object sender, CancelEventArgs e)
        {
            txtSchemaFileName.Text = dlgOpenSchema.FileName;
            lstSchemaFields.Items.Clear();
            DataTable dt = new DataTable();
            dt.ReadXmlSchema(dlgOpenSchema.FileName);
            //dsMappings.Tables.Add(dt);
            //dsMappings.Tables["tblSchemaFields"].Load(dt.CreateDataReader());

            //lstSchemaFields.DataSource = dt;
            //lstSchemaFields.DisplayMember = dt.Columns[0].ColumnName;

            foreach (DataColumn dc in dt.Columns)
            {
                lstSchemaFields.Items.Add(dc.Caption);
                //DataRow dr = dsMappings.Tables["tblSchemaFields"].NewRow();
                //dr.SetField("fieldName", dc.Caption);
                //dsMappings.Tables["tblSchemaFields"].Rows.Add(dr);
            }
        }
开发者ID:cbinding,项目名称:stellar,代码行数:20,代码来源:frmSchema2Template.cs

示例15: GetProjects

 /// <summary>
 /// full
 /// </summary>
 /// <returns></returns>
 public DataTable GetProjects()
 {
     DataTable res = new DataTable();
     res.ReadXmlSchema(HttpContext.Current.Server.MapPath(CC.PROJECTS_SCHEMA_FILE_LOCAL_PATH));
     res.ReadXml(HttpContext.Current.Server.MapPath(CC.PROJECTS_FILE_LOCAL_PATH));
     return res;
 }
开发者ID:rjankovic,项目名称:Webmin,代码行数:11,代码来源:SystemDriver.cs


注:本文中的System.Data.DataTable.ReadXmlSchema方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。