0

データを更新しようとしています。パラメータ化されたクエリを使用するたびに、エラーが発生しますFatal Error Encountered during command execution

これが私のコードです:

public void updateAccount(Int32 cashierid, string cashieruser, string isadmin, string cashierfname, string cashiermname, string cashierlname, string cashierpass)
{
    con.ConnectionString = conString;     
    String sql = "UPDATE cashieraccount SET cashieruser = ?cashieruser, cashierpass = ?cashierpass, isadmin = ?isadmin, cashierfname = ?cashierfname, cashiermname = ?cashiermname, cashierlname = ?cashierlname";
    sql += "WHERE cashierid = ?cashierid";
    try
    {
        con.Open();
        MySqlCommand cmd = new MySqlCommand(sql, con);
        cmd.Parameters.AddWithValue("?cashieruser", cashieruser);
        cmd.Parameters.AddWithValue("?cashierpass", cashierpass);
        cmd.Parameters.AddWithValue("?isadmin", isadmin);
        cmd.Parameters.AddWithValue("?cashierfname", cashierfname);
        cmd.Parameters.AddWithValue("?cashiermname", cashiermname);
        cmd.Parameters.AddWithValue("?cashierlname", cashierlname);
        cmd.Parameters.AddWithValue("?cashierid", cashierid);
        cmd.ExecuteNonQuery(); **//Fatar Error Encountered during command execution**
    }
    finally
    {
        con.Close();
    }
}

誰か提案はありますか?

4

1 に答える 1

4

where句の前に、パラメーターの後ろに空白がありません:

String sql = "UPDATE cashieraccount SET cashieruser = ?cashieruser, cashierpass = ?cashierpass, isadmin = ?isadmin, cashierfname = ?cashierfname, cashiermname = ?cashiermname, cashierlname = ?cashierlname";
sql += " WHERE cashierid = ?cashierid";
// here ^ 
于 2012-04-21T23:50:17.230 に答える