English 中文(简体)
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("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!

最佳回答

Search on an array, not a single value.

Something like:

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

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





相关问题
Reading an XLS file with the Microsoft Jet Engine

I want to allow my application to import data from XLS files. I already do this with CSV files and XML files, but would like to open the scope for users. I am having trouble with loading the file. ...

Saving nested XML in C#

I ve go the following XML file... <A> <B> <C>ValueX</C> <D>ValueY</D> </B> </A> Which I read into a DataSet to display it in a ...

Datasets do not regenerate code behind

So I was lucky enough to inherit a project where someone decided to use datasets as a model. The problem is that a column has been added to table in the database. Using the dataset desinger I added ...

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(...

Is List<> better than DataSet for UI Layer in ASP.Net?

I want to get data from my data access layer into my business layer, then prepare it for use in my UI. So i wonder: is it better to read my data by DataReader and use it to fill a List<BLClasses&...

热门标签