Saturday, May 9, 2009

How to write Stored procedure to Your Data Insert Application

Introduction:

In This article, you will understand what a stored procedure is and how to call one from SQL Sever Database.

Why Use Stored procedure?

There are several advantages of using stored procedures instead of standard SQL.

1. Stored procedures allow a lot more flexibility offering capabilities such as conditional Logic.

2. Because stored procedure are stored within the DBMS, bandwidth and execution time are reduced.This is because a single stored procedure can execute a complex set of SQL statements.

3. Sql server pre-compiles stored procedures such that they execute optimally.

4. Client developer are abstracted from complex designs.They would simply need to know that stored procedure's name and the type of fata it returns.


Here I used ASP.NET application for demonstrate this tutorial.Also this is same for the C# desktop application too.

Creating Stored procedure:

First You have to create Table name called StudentInfo and insert stored procedure for that.You can see the SQL coding for that in below.


CREATE PROCEDURE [dbo].[tblStudentInfo] - In this code, we are telling SQL Server to create a new stored procedure with the name tblStudentInfo.We Specify the body of the stored procedure after this coding part.

Calling Stored procedure:
Create a new ASP.NET Page like in below and Double click on button and do the following coding.




Coding part


After completing the coding part you can build and Run you project.If you did the all the thing correctly you can insert the data to Table via stored proocedure.

2 comments:

Chathura Jeewantha Ranasingha said...

This is an excellent article. As a frequent viewer of your fantabulous articles, i do appreciate this too..
This would be really helpful for inquisitive programmers.

Unknown said...

nice post...you can visit following link to get 100% verified code about how to store data in database using stored procedure as well as 3-tier architecture class coding.

Click Here