Before you can start coding the data access logic, you need to make sure you have the set of stored
procedures you need in order to retrieve, insert, and update information. The following code shows
the five stored procedures that are needed:
CREATE PROCEDURE InsertEmployee
@EmployeeID int OUTPUT
@FirstName varchar(10),
@LastName varchar(20),
@TitleOfCourtesy varchar(25),
AS
INSERT INTO Employees
(TitleOfCourtesy, LastName, FirstName, HireDate)
VALUES (@TitleOfCourtesy, @LastName, @FirstName, GETDATE());
SET @EmployeeID = @@IDENTITY
GO
CREATE PROCEDURE DeleteEmployee
@EmployeeID int
AS
DELETE FROM Employees WHERE EmployeeID = @EmployeeID
GO
CREATE PROCEDURE UpdateEmployee
@EmployeeID int,
@TitleOfCourtesy varchar(25),
@LastName varchar(20),
@FirstName varchar(10)
AS
UPDATE Employees
SET TitleOfCourtesy = @TitleOfCourtesy,
LastName = @LastName,
FirstName = @FirstName
WHERE EmployeeID = @EmployeeID
GO
CREATE PROCEDURE GetAllEmployees
AS
SELECT EmployeeID, FirstName, LastName, TitleOfCourtesy FROM Employees
GO
CREATE PROCEDURE CountEmployees
AS
SELECT COUNT(EmployeeID) FROM Employees
GO
CREATE PROCEDURE GetEmployee
@EmployeeID int
AS
SELECT FirstName, LastName, TitleOfCourtesy FROM Employees
WHERE EmployeeID = @EmployeeID
GO
ASP.NET, C#, SQL Server Blog
The ZEN of ASP.NET,C#,SQL Server programming
Categories
- Anonymous Methods (1)
- C# 3.0 Feature (1)
- C# 3.0 Features (1)
- Creating HTML Table Dynamically (1)
- DataView Advanced Filtering with Relationships in C# And ASP.NET (1)
- DataView and DataTable Sorting (1)
- Deserialisation between any objects (1)
- Dynamically Adding Multiple Data Tables Relationships (1)
- Filtering Data in a DataTable (1)
- How to Write Stored Procedures (1)
- Implicitly Typed Local Variables (1)
- Internet Explorer (1)
- Lambda Expressions (1)
- Lamda Expression (1)
- LinQ (1)
- LinQ to XML (1)
- Minimize All (1)
- Object Initializing (1)
- Reading the XML file (1)
- Runnig batch script from C# (1)
- Running Process from C# (1)
- Script Manager (1)
- Serialisation (1)
- SHDocVw (1)
- Sorting with a DataView (1)
- Stored Procedures (1)
- Tips and Tricks VS 2010 (1)
- Update Controls Outside Update Panel With Out Postback (1)
- Update Panel (1)
- Using Two Arguments in a Lambda Expression (1)
- Windows 7 (1)
- XML node traversal (1)
About Me
Followers
Powered by Blogger.
Blog Archive
-
▼
2008
(11)
-
▼
November
(10)
- ASP.NET C# Programmer Kerala: Advanced Filtering w...
- DataView Advanced Filtering with Relationships in ...
- Filtering with a DataView
- Sorting with a DataView
- Working with Multiple Tables and Relationships
- Stored Procedure For Insert,Delete,Update,Select C...
- Stored Procedures
- The ExecuteNonQuery() Method
- The ExecuteScalar() Method
- The ExecuteReader() Method and the DataReader
-
▼
November
(10)
Total Hits
Search
©2008. All rights Reserved
: