将我的OrderStatus'P'更新为'A'时出现问题。数据类型输入
SQL Server是varchar(50)
。
protected void grdNewOrder_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
using (SqlConnection sqlCon = new SqlConnection(constring))
{
sqlCon.Open();
string query = "UPDATE tblPurchase SET OrderStatus ='A' WHERE PurchaseID= @id";
SqlCommand sqlCmd = new SqlCommand(query, sqlCon);
sqlCmd.Parameters.AddWithValue("@id", Convert.ToInt32(grdNewOrder.DataKeys[e.RowIndex].Value.ToString()));
sqlCmd.ExecuteNonQuery();
LoadNewOrders();
lblsucessmsg.Text = "Selected Record Updated";
lblerror.Text = "";
}
}
catch (Exception ex)
{
lblsucessmsg.Text = "";
lblerror.Text = ex.Message;
}