|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Question on finding records in a ado.net vb datasethave 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. 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 If you want to search the DataSet, the below should work;
myDataSet.Tables("myTableName").Select("Lastname = 'whateverlastname' AND FirstName = 'whateverfirstname'") -- Show quoteHide quoteDennis in Houston "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. > > '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.
Refresh questions
installing my app on another computer ConnectionString property has not been initialized Retrieving file info from ftp server memeory release from un managed code installing an icon in the all users startup folder system.data.oledb Threads Question - updating UI Need to find which text box has the focus. wince, datagrid... no define >< |
|||||||||||||||||||||||