zfjyyzycl 发表于 2008-8-4 13:47

请帮忙,出现问题了

这是在模块里定义的 数据库联接
Function connection() As String '定义数据库的连接
connection = "provider=microsoft.jet.OLEDB.4.0;Data source=" + App.Path + ".\data\yyglb.mdb ;Persist Security Info=false;Jet OLEDB:Database " '设定数据库位置
End Function

但是登陆系统的时候报 我的数据库语句有错误,就是下面这个截图
[attach]36505[/attach]

登陆的完整的程序行
Public dlcs As Integer
Private Sub Command1_Click()
     If Text1.Text = "" Or Text2.Text = "" Then
        dlcs = dlcs - 1
        If dlcs >= 1 Then
            If MsgBox("对不起!您没有输入用户名或者密码,请重新输入!剩余次数:" + Str(dlcs) + "次", vbExclamation, "警告") = 1 Then
                Text1.Text = ""
                Text2.Text = ""
                Text1.SetFocus
            End If
        Else
            Call MsgBox("严重警告!您已经超过系统限定的尝试登陆次数!系统将要退出!", vbExclamation, "严重警告")
            End
        End If
        Exit Sub
    End If
    Dim cnn As New ADODB.connection
    Dim rst As New ADODB.Recordset
    sql = "select * from user where user_bh='" + Text1.Text + "' and user_pass='" + MD5(Text2.Text, "zfj") + "'"
    cnn.Open connection
    [color=DarkRed]rst.Open sql, cnn, 3, 2[/color]
    If rst.EOF Then
        rst.Close
        Set rst = Nothing
        Set cnn = Nothing
        dlcs = dlcs - 1
        If dlcs >= 1 Then
            Call MsgBox("对不起!没有该操作员或者密码不对!剩余次数:" + Str(dlcs) + "次", vbInformation, "警告")
            Text2.Text = ""
            Text2.Text = ""
            Text1.SetFocus
        Else
            Call MsgBox("严重警告!您已经超过系统限定的尝试登陆次数!系统将要退出!", vbExclamation, "严重警告")
            End
        End If
        Exit Sub
    Else
        rst("logins") = rst("logins") + 1
        rst.Update
        rst.Close
        Set rst = Nothing
        Set cnn = Nothing
        mainform.Show
        Unload Me
    End If
End Sub

Private Sub Form_Load()
dlcs = 3
End Sub

请哪位高手帮助解决!

[[it] 本帖最后由 zfjyyzycl 于 2008-8-4 13:53 编辑 [/it]]

octillion 发表于 2008-8-4 14:33

user是数据库里的保留字。
使用时加中括号

zfjyyzycl 发表于 2008-8-5 10:30

谢谢,已经解决了

页: [1]

编程论坛