求助 对象refresh的方法IaDODC失败

来源:百度知道 编辑:UC知道 时间:2024/07/09 01:13:59
我在进行实训任务登录界面运行的时候,弹出第一个方框:
实时错误:
第一行'='附近有语法错误
点击确定后又显示
“-2147217900 (80040e14)”
对象refresh的方法IaDODC失败
相关代码如下:
Private Sub Command1_Click()
Adodc1.RecordSource = "select * from userinfo where uname =" ' &text1.text&'"and upass ="'&text2.text&'""
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
MsgBox "登录成功", vbOKOnly + vbinformtion, "登陆成功提示"
form2.Load
Unload Form1
Else
MsgBox "用户名或密码错误,请重新输入", vbOKOnly + vbInformation, "登录错误提示"
End If
End Sub

Private Sub Command2_Click()
Unload Form1
End Sub
Private Sub form_load()
Adodc1.Refresh
End Sub
不能分行书写

你发错地方了 这里是C# 不是VB

错误原因
Adodc1.RecordSource = "select * from userinfo where uname =" '
&text1.text&'"and upass ="'&text2.text&'""
分行必须用_
这两行你连着写

改成
Adodc1.RecordSource = "select * from userinfo where uname ="'& text1.text &'"and upass ="'& text2.text &'""

直接复制进去看看.

符号问题:
Adodc1.RecordSource = "select * from userinfo where uname ='"+text1.text+"'and upass ='"+text2.text+"' ";