System.Data.OleDb.OleDbException: 'FROM 子句中的语法错误。'

时间:2021-06-13 10:39:50

标签: vb.net visual-studio-2019

它一直告诉我 FROM 子句中的语法错误。关于修复此代码的任何想法?我 100% 地遵循了教程,不知何故这个错误不断发生。另外我使用的是 VS2019 和 Microsoft Access 365。这是可视化的基本 .net 形式。

Public Class Form1
    Dim cmdlog As OleDbCommand
    Dim drlog As OleDbDataReader
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub

    Private Sub button1_Click(sender As Object, e As EventArgs) Handles Clear.Click

    End Sub

    Private Sub PictureBox1_Click(sender As Object, e As EventArgs)

    End Sub

    Private Sub Btn_Login_Click(sender As Object, e As EventArgs) Handles Btn_Login.Click
        Dim conn As New OleDbConnection("Provider= Microsoft.ACE.OLEDB.12.0;Data Source= C:\Users\Jane\Documents\MYSJ GA\MySJ GA\bin\Debug\Mysejahtera1.accdb")

        Dim cmdlog As OleDbCommand = New OleDbCommand("Select * from user log in where [user_ID]='" & textBoxuser.Text & "' and [user_pw]='" & textBoxpw.Text & "'", conn)
        conn.Open()
        Dim drlog As OleDbDataReader = cmdlog.ExecuteReader
        If drlog.Read() = True Then
            Me.Hide()
            Form4.Show()
            MsgBox("login successfully")
        Else
            MsgBox("login failed")
        End If

    End Sub
End Class

1 个答案:

答案 0 :(得分:0)

我认为你应该在表名中使用方括号: “从[用户登录]中选择*,其中[user_ID]='”

相关问题