0

我有一个问题,当我登录时发生错误,即没有为一个或多个必需参数提供值。

protected void imgbtn_login_Click(object sender, ImageClickEventArgs e)
{
    int UserId = 0;
    string str = ("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=pathto.mdb;Persist Security Info=False;");
    OleDbConnection conn = new OleDbConnection(str);
    conn.Open();
    string query = "select * from Users where LoginName='" + txt_logname.Text + "' and Password='" + txt_pass.Text + "';";
    OleDbDataAdapter da=new OleDbDataAdapter(query,conn);
    DataSet ds = new DataSet();

    da.Fill(ds);
    DataTable dt = new DataTable();

    dt = ds.Tables[0];
    try
    {
        UserId = Int32.Parse(dt.Rows[0]["UserId"].ToString());

        //btn_LogIn.Text = "Login Succeded";
        Response.Redirect("Register.aspx");
    }
    catch (Exception ex)
    {

    }
    txt_logname.Text = " ";
    txt_pass.Text = "";
}
4

1 回答 1

3

密码是保留字。将其放在方括号中 [密码]

请参阅INSERT INTO 语句中的语法错误

于 2012-04-13T11:02:11.020 回答