Is it super difficult to work with a mysql database, or an access database, through vb6? I know it is rather simple开发者_Python百科 with vb.net.
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
精彩评论