高手请往这边看看,关于VB中连接数据库的问题?谢谢!
为一个登陆框,用户名和密码,然后是提交
代码如下:
Private Sub Command1_Click()
Dim i As Integer
i = 1
If Text1.Text = "" Then
MsgBox "请输入用户名!"
i = 0
Else
If Text2.Text = "" Then
MsgBox "请输入密码!"
i = 0
End If
End If
Dim CON As ADODB.Connection
Set CON = New Connection
Dim rs As ADODB.Recordset
Set rs = New Recordset
CON.CommandTimeout = 3
CON.ConnectionString = "driver={sql server};server=SXJ;database=anquanyuan"
CON.Open
Set rs.ActiveConnection = CON
rs.Open "select * from log where huming='" & Text1.Text & "' AND mima='" & Text2.Text & "'"
If i = 1 Then
If rs.RecordCount > 0 Then
Form7.Show
Unload Me
End If
Else
MsgBox "请先注册!"
End If
End Sub
总是连接不上就是查询问题,其中Text1.Text 和Text2.Text为用户名和密码