Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
hello sir,
i want to create stored procedures in asp.net using c# so that i can use it further in my project. can i know abt abt stored procedures. where to create it??
Posted
Comments
sudevsu 4-Mar-15 9:19am    
Can you tell what Kind of Database are you using? To give you better understanding of creating Stored procedures
Member 11496774 4-Mar-15 9:28am    
i am using sql server management studio 2005 version
sudevsu 4-Mar-15 10:01am    
Also read the solution given by Peter Leow

 
Share this answer
 
In the object Explorer
Go to your database in SQL
Go to the folder Programmability; Go to Stored Procedure--> Right click on the folder Stored Procedure
and Click on New Stored Procedure.

You will get predefined Variable and Syntax for a Stored Procedure.
Just add your query statements after BEGIN

Once you get successful message for the Stored procedure you created.
Go to the program and check your web.config file for User name and Password for SQL if already exists
If not, give User name and password in web.config
If that is difficult for you.
Just give your connection string in the program it self

SqlConnection conn= new SqlConnection("Server=(local);DataBase=master;Integrated Security=SSPI");
                conn.Open();


and call the Stored procedure

SqlCommand cmd = new SqlCommand("StoreProcedureName",con);
cmd.CommandType=CommandType.StoreProcedure;
cmd.Parameters.AddWithValue("@value",txtValue.Text);
int rowAffected=cmd.ExecuteNonQuery();
 
Share this answer
 
Believe me Google[^] is your friend! Use it. Next time, please respect the rules[^]!

2 results returned by this site:
CREATE PROCEDURE (Transact-SQL)[^]
How to create a SQL Server stored procedure with parameters [^]
 
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