2C#获取与操作数据库结构参照.pdfVIP

  • 7
  • 0
  • 约6.53万字
  • 约 41页
  • 2021-12-10 发布于福建
  • 举报
C# C# 中如何获取数据库中表的信息和列的信息 获取表的信息: conn.Open(); string [] restrictions = new string [4]; restrictions[1] = dbo ; DataTable table = conn.GetSchema( Tables , restrictions); conn.Close(); 返回的 table 是表的所有信息,而不仅仅是名字,可以通过如下语句查看这些信息: foreach (System.Data. DataRow row in table.Rows) { foreach (System.Data. DataColumn col in table.Columns) { Console .WriteLine( {0} = {1} , col.ColumnName, row[col]); } } 要获取指定表的信息,关键是要设置数组 restrictions 的值。对于

文档评论(0)

1亿VIP精品文档

相关文档