Option Explicit
'工程->引用->Microsoft ActiveX Data Object 2.0 Library (后面为版本号)
Dim cn As New ADODB.Connection
Private Sub Command1_Click()
Dim rs As New ADODB.Recordset
rs.Open "select * from astuff", cn, adOpenDynamic, adLockOptimistic
rs.Close
Set rs = Nothing
End Sub
Private Sub Form_Load()
On Error GoTo Errhandle
cn.ConnectionString = "Driver={MySQL};Option=0;port=;stmt=;Server=orient-xxl;DataBase=orientnbcws;User=root;Password="
cn.Open
Exit Sub
Errhandle:
MsgBox Err.Description, vbExclamation
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
cn.Close
Set cn = Nothing
End Sub