1

I am getting this error saying

OleDbException was unhandled...Syntax error in From clause

My code for login is given below.

Imports System.Data.OleDb

Public Class Login

Dim con As New OleDbConnection
Dim dt As New DataTable
Dim ds As New DataSet

Private Sub Login_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\Project work\anshu\fitness_0.1\Fitness.accdb"
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncancel.Click
    Me.Close()

End Sub

Private Sub btnlogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnlogin.Click


    If check() = True Then
        Main.Show()
        Me.Hide()
    Else
        MsgBox("Enter vailid Username and Password", MsgBoxStyle.Information, "Login Validation Information")
    End If



End Sub

Public Function check()
    ds.Tables.Add(dt)
    con.Open()
    Dim da As New OleDbDataAdapter("select * from User", con)
    da.Fill(dt) ---->here is the error!

    For Each DataRow In dt.Rows
        If txtname.Text = DataRow(1) And txtpass.Text = DataRow(2) Then
            con.Close()
            Return True

        End If
    Next
    con.Close()
    Return False

End Function

End Class
1
  • 1
    Q: So you're sure you have a table "User" in your "Fitness" MS-Access database? Q: Have you tried that "select" from inside of Access to verify it works? Commented Nov 24, 2012 at 17:38

1 Answer 1

4

User is a reserved word and must be bracketed:

"select * from [User]"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.