连接的access2007数据库
下面是代码,麻烦高手给看看
Dim TIM As Integer '定义一个整型变量
Dim myval As String '定义一个字符串变量
Private Sub Form_Load()
'自动识别数据库路径
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DT_W.mdb;Persist Security Info=False"
Adodc1.RecordSource = "select * from user "
Adodc1.Refresh
End Sub
Private Sub Form_Activate()
'当记录为零时,进入系统具有所有权限
If Adodc1.Recordset.RecordCount = 0 Then
MsgBox "请先设置操作员密码和权限!", , "系统提示"
Load Form1
Form1.Show
Unload Me
Else
Text1.SetFocus
End If
End Sub
Private Sub Image1_Click()
Static itimes As Integer
Form1.StatusBar1.Panels(3).Text = Text1.Text '赋值给main.StatusBar1.Panels(4).Text
'验证操作员及密码
Adodc1.RecordSource = "select * from user where 操作员='" + Text1.Text + "'"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then '如果记录数大于零
'验证密码
If Text2.Text = Adodc1.Recordset.Fields("密码") Then
Load Form1
Form1.Show
Unload Me
Else
If Text2.Text <> Adodc1.Recordset.Fields("密码") Then
MsgBox "密码错误,请重新输入!", vbCritical, "系统提示"
itimes = itimes + 1
Text2.Text = ""
Text2.SetFocus
End If
End If
Else
MsgBox "操作员不存在,请重新输入!", vbCritical, "系统提示"
itimes = itimes + 1
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
End If
If itimes = 3 Then '错误3次,退出系统
MyMsg = MsgBox("输入错误,请向系统管理员查询!", vbCritical, "系统提示")
If MyMsg = vbOK Then End
End If
End Sub
Private Sub Image2_Click()
End
End Sub
Private Sub text2_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Image1_Click '按回车键进入
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Text2.SetFocus '按回车键,text2获得焦点
End Sub
用vb做一个登录的界面时,老是提示from子句语法错误,对象“refresh”的方法‘IAdodc’失败
答案:2 悬赏:80
解决时间 2021-11-07 08:26
- 提问者网友:西路不相离
- 2021-11-07 03:24
最佳答案
- 二级知识专家网友:糜废丧逼
- 2021-11-07 03:34
user 是保留字,要改一下SQL语句:
Adodc1.RecordSource = "select * from [user]"
Adodc1.RecordSource = "select * from [user]"
全部回答
- 1楼网友:放肆的依賴
- 2021-11-07 04:29
adouser.recordsource = "select*from 员工信息 where 业务员编号=" '_ & trim(text1) & "'"
这行错了,这样试试:
adouser.recordsource = "select * from 员工信息 where 业务员编号=‘" & trim(text1) & "'"
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯