protected void Button1_Click(object sender, EventArgs e) { string connection = ConfigurationManager.AppSettings["connection"]; SqlConnection con = new SqlConnection(connection); con.Open(); SqlCommand cmd = new SqlCommand("adminquestion", con); cmd.Parameters.AddWithValue("@ques", TextBox1.Text); cmd.Parameters.AddWithValue("@options1", TextBox2.Text); cmd.Parameters.AddWithValue("@options2", TextBox3.Text); cmd.Parameters.AddWithValue("@options3", TextBox4.Text); cmd.Parameters.AddWithValue("@options4", TextBox5.Text); cmd.CommandType = CommandType.StoredProcedure; cmd.ExecuteNonQuery(); con.Close(); }
alter procedure adminquestion @ques varchar(225), @option1 varchar(225), @option2 varchar(225), @option3 varchar(225), @option4 varchar(225) AS BEGIN INSERT INTO [dbo].[t_questions] (qtext) VALUES(@ques) INSERT INTO [dbo].[answer](aoption) select '@option1' union select '@option2' union select '@option3' union select '@option4' END
@option1 varchar(225),
cmd.Parameters.AddWithValue("@options1", TextBox2.Text);
cmd.Parameters.AddWithValue("@option1", TextBox2.Text); cmd.Parameters.AddWithValue("@option2", TextBox3.Text); cmd.Parameters.AddWithValue("@option3", TextBox4.Text); cmd.Parameters.AddWithValue("@option4", TextBox5.Text);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)