0

我的代码有问题,不知道是什么问题。任何人都可以建议吗?

整个程序用于生物识别程序。这只是登录用户控制器。我怎么解决这个问题?

我正面临着这个问题:

dbAdapter.Fill(uds);

陈述:

OleDbException 未处理:FROM 子句中的语法错误。

我的代码如下:

这是我的登录页面表单:使用以下代码。每当我单击登录时,就会出现错误。我的代码有什么问题?

我的代码如下:登录页面表格

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)
    {

    }

}
}
4

2 回答 2

3

User是一个保留关键字(至少在 SQLServer 中,请参见此处http://msdn.microsoft.com/en-us/library/ms189822.aspx)。按照 Marco 的建议尝试[User]

于 2012-11-07T07:08:55.220 回答
0

尝试使用字符串 sqlStatement = "Select * from [User]";

于 2013-03-03T21:02:39.133 回答