Results 1 to 3 of 3

Thread: Is there a way to declare an adodb recordset in VB.net

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2012
    Posts
    9

    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.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width