Retrieving a field from dataset

mistaken_myst

Active member
Joined
Oct 29, 2007
Messages
25
Programming Experience
Beginner
Hello,
I have opened an oledbconnection, declared a dataset, declare & use a oledbDataAdapter to Fill the dataset with all records from a specific table.
My Dataset was filled successfully.

I have a number "456".
How can I search for a specific record in the dataset with a field named "ID" which value = "456" ?
 
Help please, its urgent !!

cn= new OleDb.OleDbConnection("Provider = Microsoft.Jet.OLEDB.4.0;Data Source = C:\myAcc.mdb")
dim ds = new DataSet
Dim mySQL As String = "SELECT tblAcc.* FROM tblAcc;"
cn.Open()
Dim da = New OleDb.OleDbDataAdapter(mySQL, cn)
da.Fill(ds, "Details")
grid.DataSource = ds.Tables("Details")

Grid displays this:
No ID
3 245
6 488
7 457
etc..

dim x as Integer = TxtID.Text

How can I search the DataSet 'ID' field for number 'x' ? (or how can I retrieve the 'ID' field values so as to compare them to number 'x' ?)
 
DataSets dont contain fields, they contain DataTables. DataTables contain DataRows and DataRows contain values.. Please bear this in mind

Also, right now, youre downloading the entire database table to your machine then attempting to search it locally. You'd be far better off getting the database to do the searching.. Read teh PQ link in my signature, then the DW1 link about searching data.
 
:confused: I am using OLE DB - Don't know if I hav should hav posted my Topic in the OLE DB Forum instead of here. but anyway:

Thanks for replying - I hav just learned creating DataRows Array & using them. However I'm still a bit confused concerning DataTables.
1st. I am using many MDI Forms in my project. How can I pass a 'value x' from 1 childform to another?

2nd. In my code: my DataSet contains 1 DataTable, how could I make the DataSet contain 2 DataTables?
 
Last edited:
:confused: I am using OLE DB - Don't know if I hav should hav posted my Topic in the OLE DB Forum instead of here. but anyway:

Thanks for replying - I hav just learned creating DataRows Array & using them. However I'm still a bit confused concerning DataTables.
A DAtaTable is a colloection of DataRow, you dont need to make an array of datarow. It sounds like your programming knowledge might need updating! We dont often use arrays any more.


1st. I am using many MDI Forms in my project. How can I pass a 'value x' from 1 childform to another?
Same way you;d pass any other bit of information between any instance of an object in an OO programming language. Forms are nothing special.

2nd. In my code: my DataSet contains 1 DataTable, how could I make the DataSet contain 2 DataTables?
If youre using typed datasets designed in the visual designer, then you add another in there. To programmatically add one in code is more tedious, but it basically involves creating a datatable and adding it to the dataset.Tables collection
 
Back
Top