Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Scan in ADO?
Message
General information
Forum:
ASP.NET
Category:
ADO.NET
Title:
Miscellaneous
Thread ID:
00943893
Message ID:
00943895
Views:
20
This message has been marked as the solution to the initial question of the thread.
Hi, Eric,

First, here is a link that covers part of what you're asking. Some of this you may already know, but there's some good info that might help out...

http://www.c-sharpcorner.com/Code/2004/March/DataSetsIn.NETP2.asp


Second, to do the equivalent of a SEEK, you first need to define a primary key for the datatable, then you can perform an ADO.NET FIND, like so...
MyTable.PrimaryKey = new DataColumn[] {MyTable.Columns["MyColumn"]};
DataRow Dr = MyTable.Rows.Find("valuetosearch");
if(Dr!=null) {
   // run your code based on the hit
You can also create a primary key with multiple columns. Note that the primary key you define MUST be unique. If not, you'll get an error message.

Finally, as for scanning through rows, there are a couple of ways, here's what I usually do...
foreach(DataRow DrDetail in MyTable.Rows) 
   MessageBox.Show("Value of invoice id is " + DrDetail["invoiceid"].ToString());
Now...if you're scanning through a dataview associated with a rowfilter, you might want to do something like this...
MyTable.DefaultView.RowFilter = " paid = true ";
foreach(DataRow drv in MyTable.DefaultView)
   \\ code for drv
The on-line help has some additional code examples, if you search on the keywords "primary key", "rowfilter", "find", etc.

Hope that helps...
Kevin
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform