开发者

DataSet and Primary Key with multiple columns

How Can I use Find method in DataSet that has Primary Key make of 3 Columns?

        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("Location开发者_JS百科ID")
        keyColStock(2) = dsSample.Tables("StockBalance").Columns("StockBalanceUnitID")
        dsSample.Tables("StockBalance").PrimaryKey = keyColStkBal

        dRowCurrent = dsSample.Tables("StockBalance").Rows.Find("")

In Find parameter , which one I have to fill? Please help me. Thanks Everyone!


Here is a post on your problem - they suggest you pass an array of columns (for the key) and cast it to object[]

Find with more than one columns in key


Search on an array, not a single value.

Something like:

Dim ObjectFindArray(2) as Object 
...
ObjectFindArray[0] = 
...
dRowCurrent = dsSample.Tables("StockBalance").Rows.Find(ObjectFindArray)
...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜