Question on finding records in a ado.net vb dataset

N

Newbie

Could someone please tell me how or if the following is possible. I
have created a small test database and have opened one connection, one
DataAdapter, and one Dataset for it in my vb.net (ado.net) program. I
am able to Navigate through the dataset ie: MoveNext, MoveFirst,
MovePrev, MoveLast by just keeping track of my record position. I can
Add,Delete,Update Records etc by using the CommandBuilder

ie: Dim cb As New OleDb.OleDbCommandBuilder(daUsers)


Now I would Like to add a search feature using two non primary key
fields. I have been able to search for a specific record using the
dataview.find() method but from everything I could find this will only
work on one specified field. From what I have found on the web first
you sort the dataview.sort("LastName") then call the find method
dataview.find("smith"), this works for a single field only. The
problem I am having is I would like to be able to sort by multiple
fields ie: dataview.find("smith","bob") Is there a way to do that?
I have read that the dataview does not require the sort field/fields to
be a primary key field like the datarow.find requires, but I still have
not found a way to do it.
Also, back in the day's of VB version 6, I was able to use sql to
accomplish what I'm now trying to do on one recordset. ie: "SELECT *
FROM Address WHERE FirstName = "Bob" AND LastName = "Smith". You were
able to execute all kinds of query's on the same recordset. Is there
a way to do this on a vb.net dataset.

Thanks

Dave LaPorte.
 
G

Guest

If you want to search the DataSet, the below should work;

myDataSet.Tables("myTableName").Select("Lastname = 'whateverlastname' AND
FirstName = 'whateverfirstname'")
 
F

Fivel via DotNetMonster.com

'Use the dataview....

' then you can use the find and rowfilter properties .


** dim dataview1 as dataview

'** dataview1 = New DataView(dataset1.Tables(0))

' ** dataview1.RowFilter = "Lastname='Myname'"

Fivel.
If you want to search the DataSet, the below should work;

myDataSet.Tables("myTableName").Select("Lastname = 'whateverlastname' AND
FirstName = 'whateverfirstname'")
Could someone please tell me how or if the following is possible. I
have created a small test database and have opened one connection, one
[quoted text clipped - 25 lines]
Dave LaPorte.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top