我用VB查询Access里的数据,运行一个学生信息管理系统,怎么但一直出现: 对象refresh 的IADODC方法失败Private Sub cmdOK_Click()
Static error_count As Integer
If txtUserName.Text = "" And txtPassword.Text = "" Then
MsgBox "请输入用户名和密码", vbExclamation + vbOKOnly, "登陆提示"
txtUserName.SetFocus
Else
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select * from pwd where 用户名='" & txtUserName.Text & "'"
Adodc1.Refresh
If Adodc1.Recordset.EOF = True Then
MsgBox "用户名不正确,请您确认后重新输入", vbExclamation + vbOKOnly, "登陆提示"
txtUserName.Text = ""
txtUserName.SetFocus
Else
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select * from pwd where 用户名='" & txtUserName.Text & "' and 密码='" & txtPassword.Text & "'"
Adodc1.Refresh '此行出错
If Adodc1.Recordset.EOF = True Then
error_count = error_count + 1
If error_count = 3 Then
MsgBox "您是非法用户,系统即将关闭", vbCritical + vbOKOnly, "登陆提示"
Unload Me
Else
MsgBox "密码不正确,请您确认后重新输入", vbExclamation + vbOKOnly, "登陆提示"
txtPassword.Text = ""
txtPassword.SetFocus
End If
Else
If Adodc1.Recordset!权限 = "学生" Then
qx = "学生"
UserName = txtUserName.Text
MsgBox "欢迎学生登陆!" & vbCrLf & vbCrLf & "你只有学生的权限!", vbInformation + vbOKOnly, "登陆提示"
' MDIForm1.sys.Enabled = False
Login_frm.Hide
MDIForm1.Show
' MDIForm1.Enabled = False
txtUserName.Text = ""
txtPassword.Text = ""
MDIForm1.student.Enabled = True
MDIForm1.s_choice.Enabled = True
MDIForm1.stchquery.Enabled = True
MDIForm1.help.Enabled = True
MDIForm1.user.Enabled = True
MDIForm1.Command1.Enabled = True
MDIForm1.denglu.Enabled = False
MDIForm1.teacher.Enabled = False
MDIForm1.course.Enabled = False
MDIForm1.t_choice.Enabled = False
MDIForm1.tequery.Enabled = False
MDIForm1.help.Enabled = False
MDIForm1.reports.Enabled = False
MDIForm1.Command2.Enabled = False
MDIForm1.Command3.Enabled = False
MDIForm1.Command4.Enabled = False
MDIForm1.Command5.Enabled = False
MDIForm1.user_manage.Enabled = False
ElseIf Adodc1.Recordset!权限 = "老师" Then
qx = "老师"
UserName = txtUserName.Text
MsgBox "欢迎教师登陆!" & vbCrLf & vbCrLf & "你只有教师的权限!", vbInformation + vbOKOnly, "登陆提示"
'MDIForm1.sys.Enabled = False
Login_frm.Hide
MDIForm1.Show
' MDIForm1.Enabled = False
txtUserName.Text = ""
txtPassword.Text = ""
MDIForm1.teacher.Enabled = True
MDIForm1.course.Enabled = True
MDIForm1.t_choice.Enabled = True
MDIForm1.tequery.Enabled = True
MDIForm1.help.Enabled = True
MDIForm1.user.Enabled = True
MDIForm1.Command2.Enabled = True
MDIForm1.Command3.Enabled = True
MDIForm1.denglu.Enabled = False
MDIForm1.student.Enabled = False
MDIForm1.s_choice.Enabled = False
MDIForm1.stchquery.Enabled = False
MDIForm1.help.Enabled = False
MDIForm1.help.Enabled = False
MDIForm1.reports.Enabled = False
MDIForm1.Command1.Enabled = False
MDIForm1.Command4.Enabled = False
MDIForm1.Command5.Enabled = False
MDIForm1.user_manage.Enabled = False
ElseIf Adodc1.Recordset!权限 = "管理员" Then
qx = "管理员"
UserName = txtUserName.Text
MsgBox "欢迎管理员登陆!" & vbCrLf & vbCrLf & "你有所有的权限!", vbInformation + vbOKOnly, "登陆提示"
Login_frm.Hide
MDIForm1.Show
' MDIForm1.Enabled = False
txtUserName.Text = ""
txtPassword.Text = ""
End If
End If
End If
End If
End Sub
Static error_count As Integer
If txtUserName.Text = "" And txtPassword.Text = "" Then
MsgBox "请输入用户名和密码", vbExclamation + vbOKOnly, "登陆提示"
txtUserName.SetFocus
Else
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select * from pwd where 用户名='" & txtUserName.Text & "'"
Adodc1.Refresh
If Adodc1.Recordset.EOF = True Then
MsgBox "用户名不正确,请您确认后重新输入", vbExclamation + vbOKOnly, "登陆提示"
txtUserName.Text = ""
txtUserName.SetFocus
Else
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select * from pwd where 用户名='" & txtUserName.Text & "' and 密码='" & txtPassword.Text & "'"
Adodc1.Refresh '此行出错
If Adodc1.Recordset.EOF = True Then
error_count = error_count + 1
If error_count = 3 Then
MsgBox "您是非法用户,系统即将关闭", vbCritical + vbOKOnly, "登陆提示"
Unload Me
Else
MsgBox "密码不正确,请您确认后重新输入", vbExclamation + vbOKOnly, "登陆提示"
txtPassword.Text = ""
txtPassword.SetFocus
End If
Else
If Adodc1.Recordset!权限 = "学生" Then
qx = "学生"
UserName = txtUserName.Text
MsgBox "欢迎学生登陆!" & vbCrLf & vbCrLf & "你只有学生的权限!", vbInformation + vbOKOnly, "登陆提示"
' MDIForm1.sys.Enabled = False
Login_frm.Hide
MDIForm1.Show
' MDIForm1.Enabled = False
txtUserName.Text = ""
txtPassword.Text = ""
MDIForm1.student.Enabled = True
MDIForm1.s_choice.Enabled = True
MDIForm1.stchquery.Enabled = True
MDIForm1.help.Enabled = True
MDIForm1.user.Enabled = True
MDIForm1.Command1.Enabled = True
MDIForm1.denglu.Enabled = False
MDIForm1.teacher.Enabled = False
MDIForm1.course.Enabled = False
MDIForm1.t_choice.Enabled = False
MDIForm1.tequery.Enabled = False
MDIForm1.help.Enabled = False
MDIForm1.reports.Enabled = False
MDIForm1.Command2.Enabled = False
MDIForm1.Command3.Enabled = False
MDIForm1.Command4.Enabled = False
MDIForm1.Command5.Enabled = False
MDIForm1.user_manage.Enabled = False
ElseIf Adodc1.Recordset!权限 = "老师" Then
qx = "老师"
UserName = txtUserName.Text
MsgBox "欢迎教师登陆!" & vbCrLf & vbCrLf & "你只有教师的权限!", vbInformation + vbOKOnly, "登陆提示"
'MDIForm1.sys.Enabled = False
Login_frm.Hide
MDIForm1.Show
' MDIForm1.Enabled = False
txtUserName.Text = ""
txtPassword.Text = ""
MDIForm1.teacher.Enabled = True
MDIForm1.course.Enabled = True
MDIForm1.t_choice.Enabled = True
MDIForm1.tequery.Enabled = True
MDIForm1.help.Enabled = True
MDIForm1.user.Enabled = True
MDIForm1.Command2.Enabled = True
MDIForm1.Command3.Enabled = True
MDIForm1.denglu.Enabled = False
MDIForm1.student.Enabled = False
MDIForm1.s_choice.Enabled = False
MDIForm1.stchquery.Enabled = False
MDIForm1.help.Enabled = False
MDIForm1.help.Enabled = False
MDIForm1.reports.Enabled = False
MDIForm1.Command1.Enabled = False
MDIForm1.Command4.Enabled = False
MDIForm1.Command5.Enabled = False
MDIForm1.user_manage.Enabled = False
ElseIf Adodc1.Recordset!权限 = "管理员" Then
qx = "管理员"
UserName = txtUserName.Text
MsgBox "欢迎管理员登陆!" & vbCrLf & vbCrLf & "你有所有的权限!", vbInformation + vbOKOnly, "登陆提示"
Login_frm.Hide
MDIForm1.Show
' MDIForm1.Enabled = False
txtUserName.Text = ""
txtPassword.Text = ""
End If
End If
End If
End If
End Sub
解决方案 »
- word与VB的链接问题
- 关于串口编程的一些问题请高手帮忙
- 请教:VB中怎么设计多线程程序?
- 我要实现这样的效果:textbox 的 height 逐渐加大,只到指定大小为止,也就是要看出动漫效果的,能成?
- 怎么才能得到一个EXE文件是否在运行呢?我想双击个EXE文件,开始播放声音,当我第二次双击的时候停止播放?怎么实现呢?
- 大家好,今天有一个问题请教,在中国,程序员是乞丐吗?虽然我是菜鸟
- *****数据库里怎么把计算的结果由整数类型转化为其他类型*******解决了就送分!!
- 急需VB控件,帮忙有分!
- 散分,,大家过年好...........................................
- recordset可否控制删除一行?
- 要求对象的错误!!!!!!!!!急急
- 小妹求救!
要是连了就检查你的SQL语句是不是有敲错的地方!
Adodc1.Recordset.Close
Adodc1.ConnectionString ="你的连接字符串"
'加上面两句在这个地方
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select * from pwd where 用户名='" & txtUserName.Text & "' and 密码='" & txtPassword.Text & "'"
Adodc1.Refresh '此行出错