Friday, 23 August 2013
no update on sql server database. No errors just no results
no update on sql server database. No errors just no results References //the @Question column name needs to change according to the checkbox. For example Checkbox1 - Question1 SqlConnection con = new SqlConnection(...); String sql = \"UPDATE INQUIRY2 set @Question = @str WHERE email = @email AND base = @base;\"; SqlCommand cmd = new SqlCommand(sql, con); con.Open(); //checkbox2 - question 2 //if (CheckBox3.Checked == true) //{ // str = str + CheckBox3 + \'x\'; //} 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(); } //checkbox1 - question 1 if (CheckBox9.Checked == true) { str = str + CheckBox9.Text + \'x\'; strQuestOne = theDataTable.Columns[\"Question1\"].ToString(); } cmd.Parameters.AddWithValue(\"@email\", email); cmd.Parameters.AddWithValue(\"@str\", str); cmd.Parameters.AddWithValue(\"@Question\", strQuestOne); cmd.Parameters.AddWithValue(\"@base\", base1); cmd.ExecuteNonQuery(); con.Close();
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment