Syntax error converting the varchar value...
When I enter any non-integer value into the txtPriceQuoted text box, I get the error "Syntax error converting the varchar value '1.25' to a column of data type int". Within the database, the PriceQuoted field is varchar(50) and defined as such in the stored procedure. I am not trying to convert that value anywhere, so why the error?
protected void lnkSave_Click(object sender, System.EventArgs e)
{
string connString = ConfigurationManager.ConnectionStrings["crConnString"].ConnectionString;
SqlConnection cn = new SqlConnection(connString);
SqlCommand cmdUpd = new SqlCommand("Save_sp", cn);
cmdUpd.CommandType = CommandType.StoredProcedure;
if (rdbVirtualNo.Checked)
{
cmdUpd.Parameters.Add(new SqlParameter("@PricingQuotedFlag", false));
cmdUpd.Parameters.Add(new SqlParameter("@PriceQuoted", ""));
cmdUpd.Parameters.Add(new SqlParameter("@PriceApprover", ""));
}
else
{
cmdUpd.Parameters.Add(new SqlParameter("@PricingQuotedFlag", true));
cmdUpd.Parameters.Add(new SqlParameter("@PriceQuoted", txtPriceQuoted.Text));
cmdUpd.Parameters.Add(new SqlParameter("@PriceApprover", txtApproverName.Text));
}
cmdUpd.Connection.Open();
cmdUpd.ExecuteNonQuery();
cmdUpd.Connection.Close();
Response.Redirect("DetCr.aspx?CrID=" + Request.QueryString["CrID"]);
}
|