In this I will explain login example using stored procedure
in asp.net.
After good reponse of
my previous post “ Login xample in asp.net”
, I have decide to write a post for login using stored procedure in
asp.net. You will be familier to stored procedure because I have used many
procedure in my previous post. So I think that you know how to create stored
procedure in sql server . In this post I will explaine each and every thing in
simple language.
First create three tables
in sqlserver.
1 1.)
First Table :- checkUser
CREATE TABLE [dbo].[checkUser](
[userName] [nvarchar](50) NOT NULL,
[pass] [nvarchar](50) NOT NULL
)
2 2.)
Second Table :- checkUserAvailability
CREATE TABLE [dbo].[userNameAvailability](
[userName] [nvarchar](50) NOT NULL
)
3 3.)
Third Table :- newUser
CREATE TABLE [dbo].[newUser](
[userName] [nvarchar](50) NOT NULL,
[firstName] [nvarchar](50) NOT NULL,
[lastName] [nvarchar](50) NOT NULL,
[pass] [nvarchar](50) NOT NULL,
[emailId] [nvarchar](50) NOT
NULL,
[securityQuestion] [nvarchar](50) NOT NULL,
[answer] [nvarchar](50) NOT NULL
)
After that create a stored procedure for
these three tables. Here I will use stored procedure because procedure
have amny advantages over simple sql query.
Advantage of stored procedure:-
Click here .
Now it’s time to make stored procedure:-
For Table
checkUser:-
CREATE PROCEDURE sp_checkUser
(
@userName varchar(50),
@pass varchar(50)
)
AS
BEGIN
select
* from
checkUser where userName=@userName and pass=@pass;
END
GO
For Table userNameAvailability :-
CREATE PROCEDURE
sp_userNameAvailability
(
@userName varchar(50)
)
AS
BEGIN
select
* from
userNameAvailability where userName=@userName;
END
GO
For Table newUser :-
CREATE PROCEDURE sp_newUser
(
@userName varchar(50),
@firstName varchar(50),
@lastName varchar(50),
@pass varchar(50),
@emailId varchar(50),
@securityQuestion varchar(50),
@answer varchar(50)
)
AS
BEGIN
insert
into newUser(userName,firstName,lastName,pass,emailId,securityQuestion,answer) values(@userName,@firstName,@lastName,@pass,@emailId,@securityQuestion,@answer);
END
GO
to be continued………
No comments:
Post a Comment
Note: only a member of this blog may post a comment.