How do i add a primary key to my datatable through code in design time?
the reason i ask is that i am trying to take advantage of the disconnected architecture of ado.net (i am populating a dataset with a table of items(inventory), and the items are put into a listbox where a user can select one item to display the details on the item. the only way i can figure out how to fill text boxes with the corresponding selected item details is by doing a filter of the original dataset (filter by 'id' which is what i set as the data value for the listbox) using the unique 'id' column and then setting the text fields of these text boxes to the corresponding columns in the datatable row that is returned after the filter. this way i wont have to reconnect to the database and query for the listbox selected item by 'id'.
the problem here is that you have to have a primary key defined in your datatable before you can filter it....i have tried a few methods of adding a primary key at design time with code but have been unsuccessful....any help please? is this sound practice to avoid requerying the database, even if its a stored procedure? i figured it would be best practice to use the dataset in memory and just filter it?