Call a stored procedure from ado.net and pass parameter to it ?

Answer Posted / suman zalodiya

SqlConnection con = new SqlConnection("Your Databse
Connection String");

SqlCommand cmd = new SqlCommand("Stored Procedure Name",
con);

cmd.CommandType = CommandType.StoredProcedure;

cmd.Parameters.Add("@source", SqlDbType.VarChar, 50).Value
= TextBox1.Text;

cmd.Parameters.Add("@destination", SqlDbType.VarChar,
50).Value = TextBox2.Text;

con.Open();

cmd.ExecuteNonQuery();
con.Close();

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to store data in memory?

714


What is sql connection in ado.net?

719


Give an example that shows how to execute a stored procedure in ado.net?

808


Why is stored procedure used in ado.net?

783


What is ado control?

724


Explain how to bind the controls(best practice) comboboxes to the data in the dataset?

787


What are the classes in System.Data.Common Namespace?

908


What is partial class?

746


Explain the dataadapter class in ado.net?

887


What is disconnected data?

789


What are the usages of the command object in ado.net?

780


What is disconnected scenario in entity framework?

800


Explain the difference between ado and ado.net?

714


Explain what are acid properties?

776


How would you connect to a database by using .NET?

720