Issue with DAO to ADO.Net

L

LDD

Hey folks

I'm porting an app from VB6 to VB.Net... what a process!

I'm about 70% of the way through.

However I'm trying to find some information on how to upgrade the code
snippet below to make use of ADO.Net

-----------------------------------------------------
....
Dim prsFiles As DAO.Recordset

prsFiles = frmMain.DefInstance.getDatabase.OpenRecordset("tableName",
DAO.RecordsetTypeEnum.dbOpenDynaset)

End Select

prsFiles.AddNew()

prsFiles.Fields("FileName").Value = vsfilename

prsFiles.Update()

prsFiles.Close()

-----------------------------------------------------
The subroutine gets called from within a loop.

How do I modify the code to use ado.net/
Or if there is any clear documentation with samples, that would be cool to..

thanks

LDD
 
C

Cor Ligthert [MVP]

LDD,

In my opinon the only answer can be in my opinion. Buy a book about ADONET.

Very known in these newsgroups are Sceppa and Vaughn as they are active in
these newsgroups.

microsoft.public.dotnet.framework.ADONET

Your question is to general and needs to much extra information for a
newsgroup message.

Sorry

Cor
 
G

Grant Frisken

If you only have a very small amount of code to port and it doesn't use
databinding then you can use "classic" ADO from VB.NET - just add a
reference to ADODB.dll and start using the objects. You might also be
able to use DAO via COM interrop - but ADO is pretty similar in usage
to DAO.

If you have a large amount of this type of code to port and your
project uses a lot of databinding then you might want to consider
Infralution's Virtual Data Objects. This allows you to use classic
ADODB with ADO.NET databinding and can take a lot of the pain out of
porting a large application. You can download a fully functional
evaluation version at:

www.infralution.com/virtualdata.html

Grant Frisken
Infralution
 
G

Guest

Here's part of your conversion. This is an application that was in VB6 using
DAO which I've converted to VB.NET using ADO. The app uses the data from the
table to fill in a grid for viewing purposes.

Original DAO code:

Dim dbSteel As Database
Dim rsAK As DAO.Recordset
Set dbSteel = OpenDatabase("AKSteelEpstienValues.mdb")
Sql = "Select * from AKSteelData order by coil"
rsAK = dbSteel.OpenRecordset(Sql, DAO.RecordsetTypeEnum.dbOpenDynaset)

Coverted ADO code:

Dim sql As String
Dim da As OleDbDataAdapter
Dim con As OleDbConnection
Dim cmd As OleDbCommand
Dim Roll As DataSet
Me.MdiParent = CoreInfo.MDIForm1.ActiveForm
Cursor.Current = Cursors.WaitCursor
sql = "Select * from AKSteelData order by coil"
con = New OleDbConnection(OptAKCnn)
cmd = New OleDbCommand
da = New OleDbDataAdapter
cmd.Connection = con
cmd.CommandText = sql
cmd.CommandType = CommandType.Text
con.Open()
Roll = New DataSet
da.SelectCommand = cmd
da.Fill(Roll, "AKSteelData")
DataGrid1.DataSource = Roll.Tables("AKSteelData")
con.Close()
con.Dispose()
Cursor.Current = Cursors.Default
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top