what do u mean by storedprocedure? [Resolved]

Posted by Jprathap under Sql Server on 8/6/2013 | Points: 10 | Views : 2018 | Status : [Member] | Replies : 3
How to use storedprocedure in sql ?
using login and registration,(crud) function.
clear my doubts.

Advance thanks




Responses

Posted by: Bandi on: 8/7/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Satyapriyanayal has posted "Login Page Using Stored Procedure" clearly...
I just want to tell you the CRUD operations using stored procedures.. I will give you sample stored procedures for CRUD operations
Lets say we have one table called Student with columns StudentID, StudentName, Marks
--C-Create and U-Update:
CREATE PROCEDURE CreateUSP

(
@P_StudentID int,
@P_StudentName VARCHAR(30),
@P_Marks int
)
AS
BEGIN
IF EXISTS ( SELECT StudentID FROM Student WHERE StudentID=@P_StudentID)
BEGIN
UPDATE Student SET StudentName = COALESCE(@P_StudentName, StudentName), Marks = @P_Marks
WHERE StudentID = @P_StudentID;
END
ELSE
BEGIN
INSERT INTO Student VALUES(@P_StudentID, @P_StudentName, @P_Marks)
END
END
GO


-- D= Delete
CREATE PROCEDURE DeleteUSP

(
@P_StudentID int
)
AS
BEGIN
DELETE FROM Student WHERE StudentID = @P_StudentID;
END
GO


-- R = Read/ Retrieve
CREATE PROCEDURE SelectUSP

(
@P_StudentID int
)
AS
BEGIN
SELECT * FROM Student WHERE StudentID = @P_StudentID;
END
GO


Please look into the btn_login_Click() button click event code posted by "Satyapriyanayak" to understand the usage of stored procedure in C#...

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Jprathap, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jprathap on: 8/7/2013 [Member] Starter | Points: 25

Up
0
Down
thanks a lot , its very easy to understand ..........

Jprathap, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 8/7/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Can you please mark it as answer....
and you posted another thread for searching for a text in stored procedure..
can you elaborate your need?

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Jprathap, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response