VB程序报错, rs.Open sql, cnn, 0, 1 If rs.RecordCount > 0 Then
DimcnnAsNewADODB.ConnectionDimrsAsNewADODB.RecordsetDimConnstringAsStringDimsqlAsStri...
Dim cnn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim Connstring As String
Dim sql As String
Private Sub Command1_Click(Index As Integer)
If Text1.Text = "" Then
MsgBox "用户名不能为空!", vbOKOnly + vbInformation, "友情提示"
id.SetFocus
Exit Sub
End If
If Text2.Text = "" Then
MsgBox "密码不能为空!", vbOKOnly + vbInformation, "友情提示"
Password.SetFocus
Exit Sub
End If
sql = "select * from user where userid ='" & Trim(Text1) & "'and " & " password='" & Trim(Text2) & "'"
rs.Open sql, cnn, 0, 1
If rs.RecordCount > 0 Then
Form1.Hide
main.Show
Exit Sub
Else
MsgBox "输入用户名错误", 64, "提示"
End If
Exit Sub
End Sub
Private Sub Command2_Click(Index As Integer)
End
End Sub
Private Sub Form_Load()
Connstring = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=zhoujiale;Data Source=SKY1990-PC\SQLEXPRESS"
cnn.Open Connstring
Adodc1.ConnectionString = Connstring
End Sub 展开
Dim rs As New ADODB.Recordset
Dim Connstring As String
Dim sql As String
Private Sub Command1_Click(Index As Integer)
If Text1.Text = "" Then
MsgBox "用户名不能为空!", vbOKOnly + vbInformation, "友情提示"
id.SetFocus
Exit Sub
End If
If Text2.Text = "" Then
MsgBox "密码不能为空!", vbOKOnly + vbInformation, "友情提示"
Password.SetFocus
Exit Sub
End If
sql = "select * from user where userid ='" & Trim(Text1) & "'and " & " password='" & Trim(Text2) & "'"
rs.Open sql, cnn, 0, 1
If rs.RecordCount > 0 Then
Form1.Hide
main.Show
Exit Sub
Else
MsgBox "输入用户名错误", 64, "提示"
End If
Exit Sub
End Sub
Private Sub Command2_Click(Index As Integer)
End
End Sub
Private Sub Form_Load()
Connstring = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=zhoujiale;Data Source=SKY1990-PC\SQLEXPRESS"
cnn.Open Connstring
Adodc1.ConnectionString = Connstring
End Sub 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询