我想使用 c# 将数据库中的数据转换为 xml 表单我已经转换为 ino xml 表单,但是它没有给我有关架构中主键和外键的信息
我的代码是
string[] b = GetAllTables();//array that gives me the name of tables
foreach (string c in b)
{
string sqlText = "SELECT * FROM " + c;
SqlDataAdapter da = new SqlDataAdapter(sqlText, myCon);
da.SelectCommand.CommandType = CommandType.Text;
da.Fill(customer,c);
foreach (DataTable dt1 in customer.Tables)
{
for (int curRow = 0; curRow < dt1.Rows.Count; curRow++)
{
for (int curCol = 0; curCol < dt1.Columns.Count; curCol++)
{
dt1.Rows[curRow][curCol].ToString();
// System.IO.StreamWriter xmlSW = new System.IO.StreamWriter(@"D:\Customer.xml");
}
}
}
}
string xmlDS = customer.GetXml();
customer.WriteXml(xmlSW, XmlWriteMode.WriteSchema);
MessageBox.Show("successfully writed");
xmlSW.Close();