ASP.NET Stored Procedures
A stored procedure is a group of Transact-SQL statements compiled into a single execution plan. You can write stored procedure and save it into the database. If you are in a situation to using the same query over and over again, it is better to create a stored procedure instead. A sample Stored Procedure is given below :
The above code create a procedure named as 'SPAUTHORS' and it execute SQL statement that select all authors last name from authors table from the PUB database. Coding business logic into a single stored procedure offers a single point of control for ensuring that business rules are correctly enforced and improve performance.
Stored procedures can also shield users from needing to know the details of the tables in the database, users unable to access the tables directly and they can just execute the stored procedures only. The command Object in ADO.NET provides a number of Execute methods that can be used to perform the SQL queries in a variety of fashions.
To call a stored procedure from ASP.NET , set the CommandType of the Command object to Stored Procedure.
From the following source code you can see how to call a stored procedure from an ASP.NET application.
Click the following links to see full source code