注册 登录
编程论坛 VB6论坛

vb+access 用ADODC连接 做一个登录界面,本人菜鸟,求高手看下程序怎么改

bnegsh 发布于 2012-05-04 13:22, 1757 次点击
程序代码:
Private Sub Command1_Click()
If Trim(Text1.Text) <> "" And Trim(Text2.Text) <> "" Then

 Adodc1.RecordSource = "select * from 用户表 where username='" + Trim(Text1.Text) + "' and passwrod='" + Trim(Text2.Text) + "'"

 Adodc1.Refresh
   If Adodc1.Recordset.RecordCount = 1 Then
    Adodc1.Recordset.Close
    frm2.Show
    Me.Hide
   Else
    MsgBox "错误的账号或密码!", vbInformation + vbOKOnly, "错误信息"
    Text2.Text = ""
    Text1.SetFocus
   End If
ElseIf Text1.Text = "" Then

 MsgBox "账号不能为空!", vbInformation + vbOKOnly, "错误信息"

 Text1.SetFocus
Else

 MsgBox "密码不能为空!", vbInformation + vbOKOnly, "错误信息"

 Text2.SetFocus
End If
End Sub



红色为出错部分,显示ADODC1 FORM子句语法错误
7 回复
#2
bnegsh2012-05-04 13:30
出错的语句是Adodc1.Refresh
#3
风吹过b2012-05-04 17:22
那就检查前面那句吧。
Adodc1.RecordSource = "select * from 用户表 where username='" + Trim(Text1.Text) + "' and passwrod='" + Trim(Text2.Text) + "'"
#4
bnegsh2012-05-04 22:40
回复 3楼 风吹过b
我双击ADODC1 ,代码窗口不出来,弹出  用户类型未定义      求指教
#5
风吹过b2012-05-06 09:09
没引用 ADODC 库???
还是没放 ADODC 控件?
#6
bnegsh2012-05-06 12:30
回复 5楼 风吹过b
放ADODC控件了啊,与数据库连接测试已成功,一双击ADODC控件就弹出 用户类型为定义
#7
quanquanwang2012-05-09 11:44
你的单引号是在英文输入法下输入的吗
#8
Artless2012-05-09 22:42
以下是引用风吹过b在2012-5-4 17:22:51的发言:

那就检查前面那句吧。
Adodc1.RecordSource = "select * from 用户表 where username='" + Trim(Text1.Text) + "' and passwrod='" + Trim(Text2.Text) + "'"
1