Link to home
Start Free TrialLog in
Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Excel VBA/VB.net Recordsets Accesss & SQL databases

Hi

I am migrating an Excel VBA project that work with a backend Access database to a VB.net Excel Add-in that interacts with Access and SQL. The original project code uses Recordsets (as shown in the code below), which the project sponsor would like me to use in VB.net. Is this even possible (given that I need to interact with SQL as well as Access). I usually use ADO.net.


Sub RefreshList()
    'On Error Resume Next
     
    With Me.Lst_Empl
           .BoundColumn = 1
           .ColumnCount = 7
           .ColumnHeads = False
           .TextColumn = True
           .ColumnWidths = 5
           .ListStyle = fmListStyleOption
           .ColumnWidths = "100,100,60,50"
    End With
   
    Lst_Empl.Clear
    Call RSConnect
    If RSSupp.EOF Then
        'MsgBox "No Supplier Data or Recordset Lost"
        Exit Sub
    End If
   
    RSSupp.MoveFirst
    Do While Not RSSupp.EOF
    Lst_Empl.AddItem RSSupp.Fields("First_Name")
    If IsNull(RSSupp.Fields("Last_Name")) Then
        Lst_Empl.Column(1, Lst_Empl.ListCount - 1) = ""
    Else
        Lst_Empl.Column(1, Lst_Empl.ListCount - 1) = RSSupp.Fields("Last_Name").Value
    End If
   
    If IsNull(RSSupp.Fields("Employee_Type")) Then
    Else
        Lst_Empl.Column(2, Lst_Empl.ListCount - 1) = RSSupp.Fields("Employee_Type").Value
    End If
   
    If IsNull(RSSupp.Fields("Active")) Then
    Else
        Lst_Empl.Column(3, Lst_Empl.ListCount - 1) = RSSupp.Fields("Active").Value
    End If
   
    If IsNull(RSSupp.Fields("Waiter Number")) Then
    Else
        Lst_Empl.Column(4, Lst_Empl.ListCount - 1) = RSSupp.Fields("Waiter Number").Value
    End If
    If IsNull(RSSupp.Fields("EmployeeID")) Then
    Else
        Lst_Empl.Column(5, Lst_Empl.ListCount - 1) = RSSupp.Fields("EmployeeID").Value
    End If
   
    RSSupp.MoveNext
    Loop
   
End Sub
Avatar of YZlat
YZlat
Flag of United States of America image

Don't use recordset in .NET, use ADo.NET
What is Lst_Empl?
ASKER CERTIFIED SOLUTION
Avatar of YZlat
YZlat
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Murray Brown

ASKER

Thanks very much