Private Sub Command1_Click()
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim i As Integer
Dim constring As String
Dim sql As String
constring = "driver={mysql odbc 3.51 driver};data source=localhost;database=tennis;uid=root;pwd=admin"
sql = "create table t(id int not null auto_increment primary key," _
& "amount varchar(200) not null);"
con.Open constring
con.Execute sql
sql = "insert into t(amount) values('100')"
con.Execute sql
rs.CursorLocation = adUseClient
rs.Open "select * from t", con, adOpenKeyset, adLockReadOnly, adCmdText
For i = 0 To rs.RecordCount - 1
Print rs.Fields(0) & " " & rs.Fields(1)
rs.MoveNext
Next
rs.Close
con.Close
Set rs = Nothing
Set con = Nothing
End Sub
测试成功.