如何在具有3列主键的DataSet中使用Find方法?
dadSample.SelectCommand = New SqlCommand("SELECT * FROM StockBalance", conxMain)
dadSample.FillSchema(dsSample, SchemaType.Source, "StockBalance")
dadSample.Fill(dsSample, "Stock")
Dim keyColStock(3) As DataColumn
keyColStock(0) = dsSample.Tables("StockBalance").Columns("StockID")
keyColStock(1) = dsSample.Tables("StockBalance").Columns("LocationID")
keyColStock(2) = dsSample.Tables("StockBalance").Columns("StockBalanceUnitID")
dsSample.Tables("StockBalance").PrimaryKey = keyColStkBal
dRowCurrent = dsSample.Tables("StockBalance").Rows.Find("")
在Find参数中,我必须填写哪一个? 请帮我。谢谢大家!
答案 0 :(得分:2)
这是关于你的问题的帖子 - 他们建议你传递一个列数组(用于键)并将其转换为对象[]
答案 1 :(得分:1)
搜索数组,而不是单个值。
类似的东西:
Dim ObjectFindArray(2) as Object
...
ObjectFindArray[0] =
...
dRowCurrent = dsSample.Tables("StockBalance").Rows.Find(ObjectFindArray)
...