c# 的sqlconnction类的getschema方法如何获取数据库中表的外键?(200分)

  • 主题发起人 主题发起人 illday
  • 开始时间 开始时间
I

illday

Unregistered / Unconfirmed
GUEST, unregistred user!
SqlConnection con = new SqlConnection();
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();
builder.IntegratedSecurity = true;
builder.DataSource = "(local)";
builder.InitialCatalog = "xs";
con.ConnectionString = builder.ConnectionString;
con.Open();

//string[] restrictions = new string[4];
//restrictions[3] = "BASE TABLE";
//DataTable table = con.GetSchema("tables", restrictions);

如何继续获得数据库中的每个表的外键呢?

是用下面这句吗?
DataTable table = connection.GetSchema("ForeignKeys",new string[]{null,null,tableName });

好象不是,那应该怎么写呢?谢谢
 
自己顶一下,希望有人帮着回答一下
 
200分啊。竟然送不出去
 
有人跟帖我就结帖 ,200分全送给他
 
哈哈,遇到过同样问题
 
多人接受答案了。
 
www.infoxa.com
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
后退
顶部