|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Opening a query in MS Access with parameters using VB.netdone VB programming for a number of years using VB 6. He needs to open a query in an Access database that has parameters so he can work with the returned records. In VB 6, I use DAO and do it this way: Dim db As Database Dim rs As Recordset Dim qd As QueryDef Dim strPath as string Set db = DBEngine.Workspaces(0).OpenDatabase(PATH TO DATABASE) Set qd = dbDatabase.QueryDefs![QUERY NAME] qd![PARAMETER NAME] = PARAMETER TO FEED QUERY Set rs = qd.OpenRecordset() ... CODE TO USE THE RECORDSET rs.close db.close For VB.net, it appears that you have to use OLE DB and it really seems to be way more complicated than it should be. Does anyone have a code snippet where the code simply sets the recordsource to the query and passes the query the parameters so he can work with the recordset? Thanks, Craig Craig,
Reading is a lot easier, than in DAO and ADO. Updating is more difficult because of the disconnected way. However because of databinding is the total needed code much less than with DAO. Here a sample in real code (it is so simple that we have not a sample with only what you ask. What you ask is until the Fill). http://www.vb-tips.com/default.aspx?ID=bece831d-6742-4364-bd0d-203ca99d2825 To see how easy it can be done in VB2005 http://www.vb-tips.com/default.aspx?ID=1139f14a-c236-4ad7-8882-b1ed16424252 I hope this helps, Cor Show quoteHide quote "eagleofjade" <cwilliam***@youthhomesinc.org> schreef in bericht news:1143062017.185351.300390@g10g2000cwb.googlegroups.com... >I am trying to help a friend who is learning VB.net in school. I have > done VB programming for a number of years using VB 6. He needs to open > a query in an Access database that has parameters so he can work with > the returned records. > > In VB 6, I use DAO and do it this way: > > Dim db As Database > Dim rs As Recordset > Dim qd As QueryDef > Dim strPath as string > > > Set db = DBEngine.Workspaces(0).OpenDatabase(PATH TO DATABASE) > Set qd = dbDatabase.QueryDefs![QUERY NAME] > qd![PARAMETER NAME] = PARAMETER TO FEED QUERY > Set rs = qd.OpenRecordset() > > ... CODE TO USE THE RECORDSET > > rs.close > db.close > > For VB.net, it appears that you have to use OLE DB and it really seems > to be way more complicated than it should be. Does anyone have a code > snippet where the code simply sets the recordsource to the query and > passes the query the parameters so he can work with the recordset? > > Thanks, > Craig > Craig,
Sorry the first was SQL here one for OLEDB Access (is the same for 32 bits) http://www.vb-tips.com/default.aspx?ID=c8303e25-496d-4288-bc1d-58e5850daf5e Cor Show quoteHide quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> schreef in bericht news:ONodIIlTGHA.5884@TK2MSFTNGP14.phx.gbl... > Craig, > > Reading is a lot easier, than in DAO and ADO. Updating is more difficult > because of the disconnected way. However because of databinding is the > total needed code much less than with DAO. > > Here a sample in real code (it is so simple that we have not a sample with > only what you ask. What you ask is until the Fill). > > http://www.vb-tips.com/default.aspx?ID=bece831d-6742-4364-bd0d-203ca99d2825 > > To see how easy it can be done in VB2005 > > http://www.vb-tips.com/default.aspx?ID=1139f14a-c236-4ad7-8882-b1ed16424252 > > I hope this helps, > > Cor > > > "eagleofjade" <cwilliam***@youthhomesinc.org> schreef in bericht > news:1143062017.185351.300390@g10g2000cwb.googlegroups.com... >>I am trying to help a friend who is learning VB.net in school. I have >> done VB programming for a number of years using VB 6. He needs to open >> a query in an Access database that has parameters so he can work with >> the returned records. >> >> In VB 6, I use DAO and do it this way: >> >> Dim db As Database >> Dim rs As Recordset >> Dim qd As QueryDef >> Dim strPath as string >> >> >> Set db = DBEngine.Workspaces(0).OpenDatabase(PATH TO DATABASE) >> Set qd = dbDatabase.QueryDefs![QUERY NAME] >> qd![PARAMETER NAME] = PARAMETER TO FEED QUERY >> Set rs = qd.OpenRecordset() >> >> ... CODE TO USE THE RECORDSET >> >> rs.close >> db.close >> >> For VB.net, it appears that you have to use OLE DB and it really seems >> to be way more complicated than it should be. Does anyone have a code >> snippet where the code simply sets the recordsource to the query and >> passes the query the parameters so he can work with the recordset? >> >> Thanks, >> Craig >> > >
VB.NET - Issues with VB.NET FTP Class to UNIX FTP Server
what's up? reading xml Best Practices - Coding Convention Question How do you know when all databindings on form are complete? Reading Excel in VB.NET SQL Distinct DoEvents in VB.NET Committing Byte Array to Disk Building VB.NET Interface definitions from a COM interface Process BUG? |
|||||||||||||||||||||||