Click here to Skip to main content
15,117,095 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
store procedure to insert all the data into database including dropdown list,


all will be store in database using store procedure

first no second no operation result
Code For You 22-May-15 4:50am
need more clarification.
Tomas Takac 22-May-15 4:53am
This is not a question at all. What are you trying to do? What help do you need?

Do one thing
create procedure that will take only 4 parameters i.e. textbox1, textbox2, for dropdownlist use varchar(max) and result.

in dropdownlist passs comma separated values which are selected in dropdownlist.

Write logic in stored procedure for spliting that dropdownlist string and do insertion work.
Member 11507028 22-May-15 15:23pm
problem with dropdownlist
Member 11507028 23-May-15 3:03am
can u give me one example
Member 11507028 26-May-15 13:40pm
i have send u my codes please take a look ,data is not storing inside the database
the data is not storing inside the database
protected void Button1_Click(object sender, EventArgs e)
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=demo1;Integrated Security=True");

int a = Convert.ToInt32(TextBox1.Text);
int b = Convert.ToInt32(TextBox2.Text);

if (DropDownList1.Text == "add")
int sum = (a + b);
Label1.Text = Convert.ToString(sum);
dat.Text = DateTime.Now.ToString();


(DropDownList1.Text == "sub")
int sub = (a - b);
Label1.Text = Convert.ToString(sub);
dat.Text = DateTime.Now.ToString();
(DropDownList1.Text == "mul")
int mul = a * b;
Label1.Text = Convert.ToString(mul);
dat.Text = DateTime.Now.ToString();
(DropDownList1.Text == "div")
decimal div = a / b;
Label1.Text = Convert.ToString(div);
dat.Text = DateTime.Now.ToString();

SqlCommand cmd = new SqlCommand();

cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "p";

cmd.Parameters.AddWithValue("@firsttno", TextBox1.Text);
cmd.Parameters.AddWithValue("@secondno", TextBox2.Text);
cmd.Parameters.AddWithValue("@operation", DropDownList1.Text);
cmd.Parameters.AddWithValue("@result", Label1.Text);
cmd.Parameters.AddWithValue("@optime", dat.Text);
cmd.Connection = con;



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