当前位置:编程学习 > VB >>

看看下面这个VB登录系统,高手指点下!

Private Sub Cmdlog_Click() 
Set cn = New ADODB.Connection 
Set rs = New ADODB.Recordset 
cn.Open "dsn=CSPE系统" 

If Text1.Text = "" Or Text2.Text = "" Then 
MsgBox "用户名和密码不能为空!请重新输入", vbOKOnly + vbInformation, "友情提示" 
Form2.SetFocus 
Exit Sub 
End If 

Dim sql As String 
sql = "select * from 用户 where 用户名='" & Text1.Text & "'and 密码= '" & Text2.Text & "'" 
rs.CursorLocation = adUseClient 
rs.Open sql, cn, adOpenStatic, adLockReadOnly 
With rs 
If .State = adStateOpen Then .Close 
.Open sql 
If rs.EOF Then 
Try_times = Try_times + 1 
If Try_times >= 3 Then 
MsgBox "您已经三次尝试进入本系统,均不成功,系统将自动关闭", vbOKOnly + vbCritical, "警告" 
Unload Me 
Else 
MsgBox "对不起,用户名不存在或密码错误 !", vbOKOnly + vbQuestion, "警告" 
Form1.SetFocus 
Text1.Text = "" 
Text2.Text = "" 
End If 
Else 
Unload Me 
Form2.Show 
End If 
End With 
End Sub 
Private Sub Cmdcancel_Click() 
Unload Me 
End Sub 


运行结果显示不能比较text,ntext,image除非使用IS NULL或LIKE运算符 

我该怎么办? --------------------编程问答-------------------- 设断点看看什么地方报的错啊
还有注意代码最好缩进一下 --------------------编程问答-------------------- sql = "select * from 用户 where 用户名='" & Text1.Text & "'and 密码= '" & Text2.Text & "'" 
and前没有空格
--------------------编程问答--------------------

sql = "select * from 用户 where 用户名='" & Text1.Text & "' and 密码= '" & Text2.Text & "'" 
补充:VB ,  基础类
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,