From VBA to VB.Net

I wrote a Library in VBA wich make an extensive use of recordsets (ADO and DAO).

Now, I want to write it in VB.NET.
Are there any equivances to recordset in .net ? Or any strongly typed heterogeneous containers ?
I would like to stay away from COM components as much as possible.
LVL 10
Fabrice LambertFabrice LambertAsked:
Who is Participating?
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
You can open any OLE compliant object with the OLEDB namespace. It's the "catchall" for this type of operation. The strongly type namespaces, like SQLConnection, are specific to the platform. If your goal is to handle the greatest number of distinct platforms, then OLEDB would probably be your best choice.
0
 
NorieVBA ExpertCommented:
Fabrice

As far as I'm aware the VB.Net 'equivalent' of an (ADO?) recordset is the (ADO.NET?) DataSet.

There are various ways to get data into a DataSet, I think one of the most common methods would be to use a DataAdapter.
0
 
Fabrice LambertFabrice LambertAuthor Commented:
Do you have a sample on how to use this ?
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
NorieVBA ExpertCommented:
Fabrice

I don't have any examples to hand and when I search all I seem to find is examples for C#.

What database(s) are you dealing with?
0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
From my experience, a DataTable would be more like an ADO.Recordset. Here's how I open a Datatable against a SQL Server database:

Using con As New SQLConnection(YourconnectString)
  con.Open
  Using cmd As New SQLCommand
    cmd.Connection = con
    cmd.CommandText = "Your SQL Here"
    Using dt As New datatable
      dt.Load(cmd.ExecuteReader)
        For each dtr As Datarow in dt.Rows
          '/ work with each row here
        Next
    End Using
  End Using
End Using

Your "dt" object (the DataTable) would be very much like an ADO or DAO Recordset. It has Rows and Columns, and you can iterate through it. You can Search it using Select (dt.SElect etc etc)

A DataSet is a collection of Datatables.

There's also the OLEDB library, which contains the OLEDBCommand and OLEDBConnection objects. Those could be use, with the appropriate connection string, to connect to an Access database, for example.
0
 
Fabrice LambertFabrice LambertAuthor Commented:
Fabrice

I don't have any examples to hand and when I search all I seem to find is examples for C#.

What database(s) are you dealing with?
Pretty much any data source (also include text files, and excel worksheets).
0
 
Fabrice LambertFabrice LambertAuthor Commented:
Thanks you
0
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.

All Courses

From novice to tech pro — start learning today.