Saturday, 24 August 2013

update does not match the base in sql server.

update does not match the base in sql server.

//the email binds to the variable. however the "base" does not enter code
here//Question1 - Checkbox1 if (CheckBox1.Checked == true) {
SqlConnection con = new SqlConnection("Server=(local);
Database=SURVEY; Trusted_Connection=True;");
String sql = "UPDATE INQUIRY2 set Question1 = @str WHERE email =
@email AND base = @base;";
con.Open();
SqlCommand cmd = new SqlCommand(sql, con);
DataTable theDataTable = null;
// Verify that dt is actually in session before trying to get it
if(Session["dt"] != null)
{
theDataTable = Session["dt"] as DataTable;
}
//Verify that the data table is not null
if(theDataTable != null)
{
email = theDataTable.Rows[0]["email"].ToString();
base1 = theDataTable.Rows[0]["base"].ToString();
}
str = str + CheckBox1.Text + 'x';
cmd.Parameters.AddWithValue("@email", email);
cmd.Parameters.AddWithValue("@str", str);
cmd.Parameters.AddWithValue("@base", base1);
cmd.ExecuteNonQuery();
con.Close();
}

No comments:

Post a Comment