How to use and store producure in ASP.Net using parameter?How to use user control using database in ASP.Net?How to use Inner join query in ASP.Net?How to call the trigger in ASP.Net?How to store the image in SQL Server and reterive in ASP.Net?

Showing Answers 1 - 1 of 1 Answers

muthuraman

  • Aug 19th, 2006
 

        SqlConnection con = new SqlConnection ("<Connection string>");
        SqlCommand cmd = new SqlCommand();

        SqlParameter namparam;
        SqlParameter deptparam;


 private void button1_Click(object sender, EventArgs e)
        {
            cmd.Connection = con;
            cmd.CommandText = "sam_insert";
            cmd.CommandType = CommandType.StoredProcedure;

            namparam = new SqlParameter("@name_1", SqlDbType.Text,9 );
            namparam.Value = textBox1.Text;
            cmd.Parameters.Add(namparam);

            deptparam = new SqlParameter("@department_2", SqlDbType.VarChar, 30);
            deptparam.Value = textBox2.Text;
            cmd.Parameters.Add(deptparam);

   
            cmd.ExecuteNonQuery();
            MessageBox.Show("inserted");
       }

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions