1
嗨,大家好我有一个数据库中没有主键的表。我认为原因在于它只是一个有很多外键的表。我真的不知道我的SQL很差。所以表格不是由我创建的,但是在创建我的数据表时我遇到了问题。要更新我的数据集,该表需要一个主键。由于所有列都不是唯一的,所以我不得不制作复合键。任何人都知道。这里是第一个创建主键的代码。DataTable Vb.net创建复合键
'after using adapter and all the connection process to fill the dataset
Dim tableProduct As DataTable = productDataSet.Tables(0)
tableProduct.PrimaryKey = New DataColumn() {tableProduct.Columns(0)}
这里是我试图创建组合键
Dim tableProduct As DataTable = productDataSet.Tables(0)
tableProduct.PrimaryKey = New DataColumn() {tableProduct.Columns(0)}
tableProduct.PrimaryKey = New DataColumn() {tableProduct.Columns(1)}
我最近开始vb.net以前我曾在Java和PHP,jQuery和这样的。所以我不是那么经验.Net框架如果我问错了问题请告诉我,所以我可以编辑谢谢
有反正检查哪些列是primarykeys以及如何的有多少?像msgbox(keycount或其他) –
当然,PrimaryKey是一个也可以读取的数组。 'tableProduct.PrimaryKey.Length'和'for tableProduct.PrimaryKey'中的每个dc请参见[MSDN VB示例](http://msdn.microsoft.com/zh-cn/library/system.data.datatable.primarykey.aspx? cs-save-lang = 1&cs-lang = vb#code-snippet-1) – Steve
Theres仍然有些问题,但现在有几个键我猜它只是数据库谢谢!!!!! –