tags:

views:

36

answers:

1

is it supper difficult to work with a mysql database or an access database through vb6? i know it is rather simple with vb.net

+2  A: 

It should be just as easy as they are both using the OleDB database drivers on their back end. .NET uses ADO.NET to give us the objects and methods to use those drivers, while VB6 can use the old COM version of ADO, which is used quite a bit differently in code, but really the code is quite simple.

Sample VB.NET select:

Dim conn as OleDbConnection
Dim adapter as OleDbDataAdapter
Dim DS as New DataSet

conn = New OleDbConnection(connectionString)
adapter = New OleDbDataAdapter(conn, "SELECT * FROM MYTABLE")
adapter.Fill(DS)

'Iterate through DS.Tables[0].Rows

DS.Dispose
adapter.Dispose
conn.Dispose

Doing the same thing in VB6:

Dim conn As ADODB.Connection
Dim rs As ADODB.RecordSet

Set conn = New ADODB.Connection
conn.Open connectionString

Set rs = New ADODB.RecordSet
rs.Open "SELECT * FROM MYTABLE", conn
rs.MoveFirst

While Not rs.EOF
   'do something with each row
   rs.MoveNext
Wend
Steve Danner
Don't forget to add the appropriate reference to your VB6 project.
magnifico