Introduction
In this article we will create a registration
form, login form and checkemail existing form. in SQL database we create table
and stored procedure.
1. Registration Form
Step-1
Create Table
Now creating a table in SQL server database
which has the username, password and email fields. Table looks like this.
create table registrationtab
(
Username
varchar(100),
Email
varchar(100),
Password varchar(20)
)
Step-2
Create stored procedure
Now Creating stored procedure for registration.
That means values will be insert in table using stored procedure. Stored
procedure looks like that for it.
create procedure [dbo].[storlogin134]
(
@username
varchar(40),
@email
varchar(50),
@password
varchar(20)
)
as
insert into registrationtab
values(@username,@email,@password
)
Step-3
Create form for registration
Now creating a form in asp.net with the
following field which are defined in the table. The form looks like below
figure.

Figure1
Now double click on the register me button and
add following code.
Protected Sub Buttonregisterme_Click(ByVal
sender As Object,
ByVal e As EventArgs) Handles
Buttonregisterme.Click
Dim strcon As String = "Data
Source=.;uid=sa;pwd=Password$2;database=master"
Dim con As New SqlConnection(strcon)
Dim com As New SqlCommand("storlogin134",
con)
com.CommandType =
CommandType.StoredProcedure
Dim p1 As New SqlParameter("username",
TextBoxusername.Text)
Dim p2 As New SqlParameter("email",
TextBoxemail.Text)
Dim p3 As New SqlParameter("password",
TextBoxpassword.Text)
com.Parameters.Add(p1)
com.Parameters.Add(p2)
com.Parameters.Add(p3)
con.Open()
com.ExecuteNonQuery()
Labelinfo.Text =
"registered successful."
End Sub
Now run the application and enter the username, email and
password and then click on the register me Button to save the values in
database.

Figure2
Open the database and check it in registrationtab table.
2. Login form
Step-4
Create stored procedure
Now Creating stored procedure for login. That
means values will be match in table using stored procedure. Stored procedure
looks like that for it.
create PROCEDURE CheckUser
(
@username
as varchar(50),
@password
as varchar(50)
)
AS
SELECT * FROM
registrationtab WHERE username=@username
AND password=@password
Now creating a form in asp.net with the
following field which are defined in the table. The form looks like below
figure.

Figure3
Step-5
Create form for login
Now creating a form in asp.net with the
username and password field which are defined in the table. The form looks like
below figure.
Figure4
Now double click on the login button and add
following code.
Protected Sub Buttonlogin_Click(ByVal
sender As Object,
ByVal e As EventArgs) Handles
Buttonlogin.Click
Dim strcon As String = "Data Source=.;uid=sa;pwd=Password$2;database=master"
Dim con As New SqlConnection(strcon)
Dim com As New SqlCommand("CheckUser",
con)
com.CommandType =
CommandType.StoredProcedure
Dim p1 As New SqlParameter("username",
TextBoxusername.Text)
Dim p2 As New SqlParameter("password",
TextBoxpassword.Text)
com.Parameters.Add(p1)
com.Parameters.Add(p2)
con.Open()
Dim rd As SqlDataReader = com.ExecuteReader()
If rd.HasRows Then
rd.Read()
Labelinfo.Text =
"Login successful."
Else
Labelinfo.Text =
"Invalid username or
password."
End If
End Sub
Now run the application and enter the username and password and
then click on the login Button to match the values with database. Suppose we
enter wrong username and password.

Figure4
Now enter correct username and password.

Figure5
3. check existence
Step-6
Check email Existence
Now Creating stored procedure for Check email existence. Stored procedure looks like that for it.
create PROCEDURE existance
(
@email
as varchar(50)
)
AS
SELECT * FROM
registrationtab WHERE email=
@email
Now creating a form in asp.net with the email
field which are defined in the table. The form looks like below figure.

Figure6
Step-7
Now double click on the login button and add
following code.
Protected Sub Buttonchekexistance_Click(ByVal sender As Object, ByVal e
As EventArgs)
Handles Buttonchekexistance.Click
Dim strcon As String = "Data Source=.;uid=sa;pwd=Password$2;database=master"
Dim con As New SqlConnection(strcon)
Dim com As New SqlCommand("existance",
con)
com.CommandType =
CommandType.StoredProcedure
Dim p1 As New SqlParameter("email",
TextBoxemail.Text)
com.Parameters.Add(p1)
con.Open()
Dim rd As SqlDataReader = com.ExecuteReader()
If rd.HasRows Then
rd.Read()
Me.Labelinfo.ForeColor = System.Drawing.Color.Red
Me.Labelinfo.Text = "already Exist!"
Else
Me.Labelinfo.Text = "you can login now"
Me.TextBoxusername.Text = ""
Me.TextBoxpassword.Text = ""
Me.TextBoxemail.Text = ""
End If
End Sub
Now run the application and enter the username, email and
password to check existence emailid with database. Suppose we enter a new email
id.

Figure7
Now and then click on the check existence Button.

Figure8
Now enter a exist email id and click on the check existence
Button.

Figure9