vb连接mysql数据库后怎么获取数据
1个回答
展开全部
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
'工程->引用->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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询