haii
i am a beginner in asp.net....i want to change my work by using stored procedore..i want to enter the empid,name,dept to database by using stored procedure....
haii
i am a beginner in asp.net....i want to change my work by using stored procedore..i want to enter the empid,name,dept to database by using stored procedure....
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Blocked AccountRank #403 · 6.2K reputationPosted Jan 17, 2008, 1:55 AM EST
For calling the stored procedure , u have to pass the parameter name and value.
here I am writing the code, which shows the way of calling the SP.
// create and open a connection object
conn = new
SqlConnection("Define Connection here.");
conn.Open();
// create a command object identifying
// the stored procedure name InsertEmpRecord
SqlCommand cmd = new SqlCommand("InsertEmpRecord", conn);
// set the command object so it knows
// to execute a stored procedure
cmd.CommandType = CommandType.StoredProcedure;
// add parameter to command, which
// will be passed to the stored procedure
cmd.Parameters.Add(
new SqlParameter("@EmpID", "Pass the value here"));
cmd.Parameters.Add(
new SqlParameter("@Name", "Pass the value here"));
cmd.Parameters.Add(
new SqlParameter("@Deptt", "Pass the value here"));
cmd.ExecuteNonQuery();
by this way u can call the sp.
Simply write the Stored Procedure. and use this code.
Happy Coding!!
ganga nair6 reputationPosted Jan 19, 2008, 12:14 AM EST
thank u.........i tried its working
but i want to know one thing also...can i use more than one action ina procedure..means....i tried one stored procedure for insert...in tha same application i want to delete,update,select also......for that i have to write separate procedure or same procedure for all those actions...
Guest UserRank #1,422 · 1.2K reputationPosted Jan 19, 2008, 1:35 PM EST
Vijaya KadiyalaRank #1,085 · 1.8K reputationPosted Mar 8, 2008, 12:12 PM EST
Hi,
The Best thing would be creating one stored procedure for all insert, update, delete actions on the table. You can you al these differernt actions in one single procedure with in Different BEGIN block and having different transactions for each of these.
Thanks -- Vj
http://dotnetvj.blogspot.com