Excle,Access Mysql 接続手順
Sub sql()
Dim cn As New ADODB.Connection
cn.ConnectionString = "Driver={MySQL ODBC 8.0 Unicode Driver};" & _
"Server=localhost;" & _
"Database=mysql;" & _
"User=root;" & _
"Password=toor"
cn.Open
Dim rn As New ADODB.Recordset
rn.Open "select User,Host from mysql.user", cn
Do Until rn.EOF
Debug.Print rn("Host"), rn("User")
Debug.Print rn!host, rn!user
rn.MoveNext
Loop
rn.Close
cn.Close
End Sub
その2
Sub samp2()
Dim cn As New ADODB.Connection
cn.Open "DRIVER={MySQL ODBC 8.0 Unicode Driver};Server=localhost;Database=mysql;User=root;Password=toor"
Dim rn As New ADODB.Recordset
Set rn = cn.Execute("select * from mysql.user")
Do Until rn.EOF
Debug.Print rn!host, rn!User
rn.MoveNext
Loop
Debug.Print "samp2"
rn.Close
cn.Close
End Sub