views:

269

answers:

2

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("LocationID")
        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!

+2  A: 

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

Dani
Thanks a lot Dani! :)
RedsDevils
+1  A: 

Search on an array, not a single value.

Something like:

Dim ObjectFindArray(2) as Object 
...
ObjectFindArray[0] = 
...
dRowCurrent = dsSample.Tables("StockBalance").Rows.Find(ObjectFindArray)
...
gbn
Thanks gbn! Your Answer is great!
RedsDevils