Derek
Derek

Reputation: 249

Syntax error in FROM clause on DataAdapter.Fill()

I am having a problem with my codes, not knowing whats the issue. Can anyone advise?

The whole program is for a biometric program. This is just the login User controller. How can i solve this problem?

I am facing this problem in the line:

dbAdapter.Fill(uds);

Stating:

OleDbException was unhandled:Syntax error in FROM clause.

My codes are below:

This is my login page form: With the following codes. Whenever i click login, the errors come up. Whats wrong with my codes?

My codes are below:LOGIN PAGE FORM

namespace Privacy_Biometric_Defender
{
public partial class Login : Form
{
    //A kind of gobal var to share in project
    public static string fixedUName;

    public Login()
    {
        InitializeComponent();
    }

    private void LoginClearButton_Click(object sender, EventArgs e)
    {
        LoginUsernameTextBox.Clear();
        LoginPasswordTextBox.Clear();
        LoginUsernameTextBox.Focus();
    }

    private void Login_Load(object sender, EventArgs e)
    {
        LoginUsernameTextBox.Focus();
    }

    private void LoginButton_Click(object sender, EventArgs e)
    {

        string userName = this.LoginUsernameTextBox.Text;
        MessageBox.Show("Codes Stops Here");
        UserController cont1 = new UserController();
        User SearchUserName = new User();      
        // Passing textbox input to Controller
        fixedUName = LoginUsernameTextBox.Text;
        SearchUserName = cont1.SearchUserName(userName);

        string passwd = this.LoginPasswordTextBox.Text;
        UserController cont2 = new UserController();
        User SearchPassword = new User();
        // Passing textbox input to Controller
        SearchPassword = cont2.SearchPassword(UserController.GetSHA512(passwd));

        // Collect information from Controller
        string checkUnameExist = UserController.uNameExist;
        string checkPasswordExist = UserController.passwordExist;
        string checkRoleExist = UserController.roleExist;

        if (checkPasswordExist == "Exists" && checkUnameExist == "Exists")
        { 
            MessageBox.Show("Login Successfully");
        }
        else
        {
            MessageBox.Show("Login Unsuccessfully!");
        }   
    }

    private void LoginUsernameTextBox_TextChanged(object sender, EventArgs e)
    {

    }

}
}

Upvotes: 0

Views: 1467

Answers (2)

BesLoi
BesLoi

Reputation: 171

Try with string sqlStatement = "Select * from [User]";

Upvotes: 0

yu_ominae
yu_ominae

Reputation: 2935

User is a reserved keyword (at least in SQLServer, see here http://msdn.microsoft.com/en-us/library/ms189822.aspx). Try with [User] as suggested by Marco.

Upvotes: 3

Related Questions