DataAdapter.Fill()上FROM子句中的语法错误

时间:2012-11-07 06:45:51

标签: c# sql ms-access exception-handling ado.net

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

整个计划适用于生物识别计划。这只是登录用户控制器。我该如何解决这个问题?

我在这行中遇到了这个问题:

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

    }

}
}

1 个答案:

答案 0 :(得分:0)

尝试使用字符串sqlStatement ="从[用户]中选择*&#34 ;;