Is there a way to declare an adodb recordset in VB.net
I am converting my VB6 code to VB.Net. I am using VS2015 Community edition.
I had a handy Function in my VB6 code called "GetReadWriteRecordset". In my form code I could create a SQL Query and pass that to my routine. I used this extensively having only to change the SQL code in whatever part of the program calling the function. I could then update/insert/ delete the record/records returned, as needed.
e.g.
Code:
Dim rs As ADODB.Recordset
Dim sSQL As String, bSuccessful As Boolean
sSQL = "SELECT [table].[ProductCode], [table].[Quantity], [table].WarehouseCode " & _
"From [table] " & _
"WHERE ((([table].ProductCode)= '" & sProdCode & "' ) " & _
"AND (([table].WarehouseCode)= '" & sWhseCode & "' )) "
Set rs = GetReadWriteRecordset(sSQL, bSuccessful)
If bSuccessful Then
rs![QuantityOnOrder] = rs![QuantityOnOrder] - (dblQtyOrd - dblQtyRec)
If rs![QuantityOnOrder] < 0 Then
rs![QuantityOnOrder] = 0
End If
rs.Update
End If
Exit Sub
I am not sure how to declare the recordset as an adodb recordset or if it is possible.
Any help will be appreciated.
Re: Is there a way to declare an adodb recordset in VB.net
1. You have posted in the VB.NET CodeBank forum, which is for sharing working code snippets. I have asked the mods to move this thread to the VB.NET forum.
2. You can use ADODB in VB.NET and I find it hard to believe that any web search on the subject wouldn't have told you that. Like for any other type, you need to start by referencing the library in which the type is defined.
3. Just because you can use ADODB in .NET doesn't mean that you should. If you're going to use .NET then use it, which means using ADO.NET for your data access. If you want to create a DAL then go ahead, using ADO.NET. That means that methods that retrieve data might return a DataTable or DataSet and methods that save data would accept them as arguments.
Re: Is there a way to declare an adodb recordset in VB.net
Thread moved from the 'CodeBank VB.Net' forum (which is for you to post working code examples, not questions) to the 'VB.Net' forum