Working with T-SQL Stored Procedures using ADO.NET
(Page 1 of 4 )
In this series, I shall try to remove all kinds of confusion about calling stored procedures from within ADO.NET. I shall also explain how to write your own stored procedures and execute them from within ADO.NET. I start with the simplest and end with the most advanced way of executing the stored procedures.
A downloadable file for this article is available
here.
Every programmer knows that stored procedures play a great role in developing multi-tier applications. Most of the experienced programmers work with stored procedures in a traditional fashion, and I agree that it really works.
But the technology has greatly improved from our traditional methods. Now we face several of the latest standards like XML, web services, external routines, and so on. I bet not every programmer uses all of them in developing their applications.
In this series, I wanted to start with the simplest traditional way of working with stored procedures. Gradually, I will add a few more series (all tying into one another) to work with most advanced trends in working with stored procedures.
But at this moment, this article focuses on the basics of stored procedures and how to call them from ADO.NET. I included the source code in the form of a single file (".zip" file). You need to extract the folders from the zip and configure the virtual directories on your own.
For the sake of this demonstration, I created two tables, "emp" and "dept," within the "Northwind" database. The "emp" table has been created with the following column structure:
Empno (int)
Ename (varchar)
Sal (float)
Deptno (int)
Similarly, I have the "dept" table with the following structure:
Deptno (int)
Dname (varchar)
Location (varchar)
I ask that you create those two tables, as all of the stored procedures in this article are heavily dependent on the above two tables.
Next: How to execute a simple stored procedure using ADO.NET from ASP.NET >>
More MS SQL Server Articles
More By Jagadish Chaterjee