我用VB和SQL做一个登陆界面我的表单只有一个combo1和一个text1,很一个确定按钮,跪求高手指点下错误在哪 5
DimcnAsNewADODB.ConnectionDimrsAsNewADODB.RecordsetDimSqlAsStringPrivateSubconme_Clic...
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim Sql As String
Private Sub conme_Click()
cn.ConnectionString = "Provider=SQLOLEDB;Data Source='';Initial Catalog=DBworkcheck;User ID=sa;Password=;"
cn.Open
If rs.State = adStateOpen Then rs.Close
Sql = "select * from tbUsers where UserId='" & Trim$(Combo1.Text) & "' "
rs.CursorLocation = adUseClient
rs.Open Sql, cn, adOpenKeyset, adLockPessimistic
If Combo1.Text = "" Then
MsgBox "用户名不能为空!", vbOKOnly + vbInformation, "友情提示"
Combo1.SetFocus
Exit Sub
End If
If Text1.Text = "" Then
MsgBox "密码不能为空!", vbOKOnly + vbInformation, "友情提示"
Text1.SetFocus
Exit Sub
End If
If rs.EOF = True Then
MsgBox "没有这个用户,请重输入!", vbOKOnly + vbExclamation, ""
Combo1.Text = ""
Combo1.SetFocus
Else
UserId = Combo1.Text
If Trim(rs.Fields(1)) = Trim(Text1.Text) Then
Unload Me
Form2.Show
Else
MsgBox "密码不正确!", vbOKOnly + vbInformation, "友情提示"
Text1.SetFocus
Text1.Text = ""
End If
End If
End Sub
我按这个程序输入 它老提示我对象打开时,不容许操作 展开
Dim rs As New ADODB.Recordset
Dim Sql As String
Private Sub conme_Click()
cn.ConnectionString = "Provider=SQLOLEDB;Data Source='';Initial Catalog=DBworkcheck;User ID=sa;Password=;"
cn.Open
If rs.State = adStateOpen Then rs.Close
Sql = "select * from tbUsers where UserId='" & Trim$(Combo1.Text) & "' "
rs.CursorLocation = adUseClient
rs.Open Sql, cn, adOpenKeyset, adLockPessimistic
If Combo1.Text = "" Then
MsgBox "用户名不能为空!", vbOKOnly + vbInformation, "友情提示"
Combo1.SetFocus
Exit Sub
End If
If Text1.Text = "" Then
MsgBox "密码不能为空!", vbOKOnly + vbInformation, "友情提示"
Text1.SetFocus
Exit Sub
End If
If rs.EOF = True Then
MsgBox "没有这个用户,请重输入!", vbOKOnly + vbExclamation, ""
Combo1.Text = ""
Combo1.SetFocus
Else
UserId = Combo1.Text
If Trim(rs.Fields(1)) = Trim(Text1.Text) Then
Unload Me
Form2.Show
Else
MsgBox "密码不正确!", vbOKOnly + vbInformation, "友情提示"
Text1.SetFocus
Text1.Text = ""
End If
End If
End Sub
我按这个程序输入 它老提示我对象打开时,不容许操作 展开
展开全部
UserId = Combo1.Text
If Trim(rs.Fields(1)) = Trim(Text1.Text) Then
Unload Me
Form2.Show
Else
====================
If Trim(rs.Fields(1)) = Trim(Text1.Text) Then
这里,fields(1)是一个集合。不能和Trim(Text1.Text) 比较。
我要用启悄一般就是
sql="select * from tbUsers where UserId='"友前 & Trim$(Combo1.Text) & "好旁清' and pwd =' " & trim$(text1.text) & " ' "
If rs.EOF Then
MsgBox "用户或密码错误。!", vbOKOnly + vbExclamation, ""
Combo1.Text = ""
me.text1.text=""
Combo1.SetFocus
Else
..........
If Trim(rs.Fields(1)) = Trim(Text1.Text) Then
Unload Me
Form2.Show
Else
====================
If Trim(rs.Fields(1)) = Trim(Text1.Text) Then
这里,fields(1)是一个集合。不能和Trim(Text1.Text) 比较。
我要用启悄一般就是
sql="select * from tbUsers where UserId='"友前 & Trim$(Combo1.Text) & "好旁清' and pwd =' " & trim$(text1.text) & " ' "
If rs.EOF Then
MsgBox "用户或密码错误。!", vbOKOnly + vbExclamation, ""
Combo1.Text = ""
me.text1.text=""
Combo1.SetFocus
Else
..........
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
数据库链接有问题。ACCESS和SQL语名同时用。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
function 里局衡面的内容是针仿腊岁对第一个表单里面文本框写的,文本框的名字是ka,kb,kc,而第二个表单里面没有这3个元素,只有q1,q2,q3,这3个,备睁所以会出现错误
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询