Click here to Skip to main content
16,010,394 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
I don't get it where i am wrong can anyone help me??

code used :

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();
    }




as i want these four option in one column

What I have tried:

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
Posted
Updated 13-Jul-17 0:02am

@option1 varchar(225),


cmd.Parameters.AddWithValue("@options1", TextBox2.Text);


See the problem?

Edit: Your SP isn't going to work anyway
 
Share this answer
 
v2
spell check

cmd.Parameters.AddWithValue("@option1", TextBox2.Text);
       cmd.Parameters.AddWithValue("@option2", TextBox3.Text);
       cmd.Parameters.AddWithValue("@option3", TextBox4.Text);
       cmd.Parameters.AddWithValue("@option4", TextBox5.Text);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900