Question

[UPDATE: MS SQL Server 2005]

Hi is it possible to select a bunch of values, and then assign a column in the select statement as the primary key?

SELECT ID FROM HQ AS PRIMARYKEY -- this is wrong
SELECT Names FROM Stores
SELECT PRODUCTNAME FROM PRODUCTS

I ask this because I want to take advantage of the DataRow find method in .net, thank you.

Was it helpful?

Solution

After populating your dataset, you have to specify the primary key with the DataTable object, not in your sql query.

myTable.PrimaryKey = new DataColumn[] {
    myTable.Columns["SomeColumn"]
};

Then you can use the Find() method

OTHER TIPS

No I don't think you can do that, that is have SQL server pass a ready index to the .NET app. You can add an index to the DataTable which will hold the data, it will be build on the client side.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top