开发者

Differences between ETL with vb.net and vb6

开发者 https://www.devze.com 2022-12-22 06:04 出处:网络
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 Ole

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
0

精彩评论

暂无评论...
验证码 换一张
取 消