Convert from Access VBA to VB.net 2010

How to convert this VBA code to VB.net?

Dim xlObj As Object
            Dim rs As DAO.Recordset

            Dim rs1 As DAO.Recordset
            

            Dim shtCnt As Integer
            Dim j As Integer

            Dim strCommandName As String

            strCommandName = "cmdRunBench"



            myDSrs = New DataSet()
            myDSrs = GetDataSet("MainHeader", "myTable")


            xlObj = CreateObject("excel.application")
            xlObj.Workbooks.Add()
            With xlObj
                .Visible = True
                shtCnt = .Worksheets.Count
                Do
                    myDSrs1 = New DataSet()
                    myDSrs1 = GetDataSet("Select * from MainDetails where IDNo=" & myDRrs("IDNo"), "myTable")
                    .Worksheets(shtCnt).Activate()

Open in new window


I really appreciate your help.
Queennie LAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
That looks like a hodge-podge between VBA and some .NET stuff (the Dataset is a commonly used Object in .NET).

In .NET, "Recordsets" would become either a Dataset or perhaps a DataTable (or something along those lines, depending on exactly what you need to do with it). You'd typically use a Command object to load those things, and your Command object would need some form of Connection objects. I often do this to fill a Datatable:

Using con As New SQLConnection
  con.ConnectionString = "blah blah"
  con.Open
  Using cmd As New SQLCommand
    cmd.Connection = con
    cmd.CommandText = "SELECT * FROM SomeTable"
    Using dt As New Datatable
      dt.Load(cmd.ExecuteReader)
      '/ dt is loaded and ready for use
    End Using
  End Using
End Using

As far as the Excel stuff, you'd typically need to use the Interops assembly for that:

https://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel%28v=office.15%29.aspx?f=255&MSPPError=-2147217396

The Interops would have to be installed and available on your development machine, as well as any machine where your program will be used.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Queennie LAuthor Commented:
Thank you.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.