VB登陆 from 子句语法错误

来源:百度知道 编辑:UC知道 时间:2024/05/25 00:00:46
Private Sub Command2_Click()
Dim cc As String, mm As String
cc = Trim(Text1.Text)
mm = Trim(Text2.Text)
If cc = "" And mm = "" Then
MsgBox "姓名不能为空,请输入!", vbOKOnly + vbExclamation, "同学/友情—登录"
Text1.SetFocus
Else
If cc = "" Or mm = "" Then
MsgBox "姓名或密码不能为空,请输入!", vbOKOnly + vbExclamation, "同学/友情—登录"
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
Else
Adodc1.RecordSource = "select * from load where name='" & cc & "' and passwd='" & mm & "'"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount <> 0 Then
Unload Me
main.Show
Else
ans = MsgBox("对不起,密码错误,无此信息", 17, "同学/友情—登录")
Text1.Text = ""
Text2.Text = &qu

建议:把
cc = Trim(Text1.Text)
mm = Trim(Text2.Text) 改为:
-------------
cc = Text1.Text
mm = Text2.Text
--------------再运行一下;
记住:要精确计算,表的字段与变量同时;不要一个精确,而一个不变,动手试一试吧!祝你成功!!1

用ADO吧,我下面这段代码你再改改就可以了。
你需要建立一个数据库来保存这些用户信息。
数据库的设计包括两个字段,分别保存用户名和密码。数据库名叫“yusion”
表名叫“user”

写代码之前你需要引用ado 控件
具体的办法是添加部件的对话框中选中
microsoft Active Data ...Object control 这句不是很记得怎么写了。
Private Sub command1_click()
dim conn as new adodb.connection
dim rs as new adodb.recordset
dim str as string
Static logintimes As Integer
dim sql as string
str = App.Path
If Right(str, 1) <> "\" Then
str = str + "\"
End If
str = "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=" & str & "\yusion.mdb"
conn.open str
rs.cursorlocation=aduseclient
sql="select * from user where 用户名='"