lingers says:
Does spaces in mssql statement prevent it from working well
Yes. So use Trim function and use parameterized query.
Refer below modified code.
double yield1 = Convert.ToDouble(Session["qpr"]);
double yi1 = input1 / yield1;
string updateSQL;
updateSQL = "update stock set qtyprod = @qtyprod , lastprod = @lastprod, totalrev= @totalrev where no = @No and active ='1' ";
dbConn.ConnectionString = WebConfigurationManager.ConnectionStrings["DB_SCH"].ConnectionString;
cmd.Connection = dbConn;
cmd.CommandText = updateSQL;
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@qtyprod", input1);
cmd.Parameters.AddWithValue("@lastprod", input1);
cmd.Parameters.AddWithValue("@totalrev", yi1);
cmd.Parameters.AddWithValue("@no", name.Trim());
try
{
dbConn.Open();
int updated = cmd.ExecuteNonQuery();
dbConn.Close();
if (updated == 1)
{
// Response.Redirect("changepassw.aspx");
}
else
{
// Label101.Text = "Process not Completed";
}
}
catch (Exception err)
{
Response.Write(err.ToString());
}
finally
{
dbConn.Close();
}