Syntax error in FROM clause

acnice

Member
Joined
Feb 18, 2010
Messages
10
Location
Colombo , Sri Lanka
Programming Experience
Beginner
I want to create a Login form..Usernames are listed in a combo box..
this code gives me an error called "Syntax error in FROM clause."
please help me..



VB.NET:
Imports System.Data.OleDb
Public Class frmLogin
    Public intUserId As Integer
    Private Sub frmLogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
    Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
        Dim strPasswordwordField As String
        Dim strPassword As String
        Dim blnLoginSuccess As Boolean

        Dim cmLogin As New OleDbCommand
        Dim adLogin As New OleDbDataAdapter
        Dim dsLogin As New DataSet
        Dim drLogin As DataRow

        intUserId = cbxUserName.SelectedIndex + 1 'UserName already listed in the Combobox
        strPasswordwordField = txtPassword.Text

        cmLogin.Connection = Con
        cmLogin.CommandText = "SELECT * FROM User "
        adLogin.SelectCommand = cmLogin
      [COLOR="Red"][SIZE="4"]  adLogin.Fill(dsLogin, "User")[/SIZE][/COLOR]
        Con.Close()

        drLogin = dsLogin.Tables("Login").Rows(intUserId - 1)
        strPassword = drLogin.Item("Password")

        blnLoginSuccess = strPasswordwordField.Equals(strPassword)

        If blnLoginSuccess Then
            MsgBox("Login Success")
        Else
            MsgBox("Login Failed")
        End If



    End Sub


this is my connection module


VB.NET:
Imports System.Data.OleDb
Module Connection
    Public Con As New OleDbConnection
    Sub Main()
        Con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data source=" & Application.StartupPath & _
        "\boarding.accdb"
        Try
            Con.Open()

        Catch ex As Exception
            MsgBox("database connection Error")
        End Try

        Dim frmlogin As New frmLogin
        frmlogin.ShowDialog()

    End Sub

End Module
 
i found my error
VB.NET:
Imports System.Data.OleDb
Public Class frmLogin
    Public intUserId As Integer
    Private Sub frmLogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
    Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
        Dim strPasswordwordField As String
        Dim strPassword As String
        Dim blnLoginSuccess As Boolean

        Dim cmLogin As New OleDbCommand
        Dim adLogin As New OleDbDataAdapter
        Dim dsLogin As New DataSet
        Dim drLogin As DataRow

        intUserId = cbxUserName.SelectedIndex + 1 'UserName already listed in the Combobox
        strPasswordwordField = txtPassword.Text

        cmLogin.Connection = Con
        cmLogin.CommandText = "SELECT * FROM UserTable "
        adLogin.SelectCommand = cmLogin
        adLogin.Fill(dsLogin, "[COLOR="Red"]UserTable"[/COLOR])
        Con.Close()

        drLogin = dsLogin.Tables("[COLOR="Red"]UserTable[/COLOR]").Rows(intUserId - 1)
        strPassword = drLogin.Item("Password")
        'strPassword = "1"
        blnLoginSuccess = strPasswordwordField.Equals(strPassword)

        If blnLoginSuccess Then
            MsgBox("Login Success")
        Else
            MsgBox("Login Failed")
        End If



    End Sub
End Class
 
Back
Top