Home All Groups Group Topic Archive Search About

Question on finding records in a ado.net vb dataset

Author
19 Jan 2006 8:38 PM
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.

Author
20 Jan 2006 6:51 AM
Cor Ligthert [MVP]
Dave,

Take the other overloaded version from the dataview.find (with the object
array)

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadataviewclassfindtopic2.asp

I hope this helps,

Cor
Author
21 Jan 2006 1:26 AM
Dennis
If you want to search the DataSet, the below should work;

myDataSet.Tables("myTableName").Select("Lastname = 'whateverlastname' AND
FirstName = 'whateverfirstname'")
--
Dennis in Houston


Show quoteHide quote
"Newbie" wrote:

> 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.
>
>
Author
22 Jan 2006 7:40 PM
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.

Dennis wrote:
Show quoteHide quote
>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.

--
Message posted via http://www.dotnetmonster.com