01.
<%@ Control Language=
"vb"
AutoEventWireup=
"false"
CodeBehind=
"loginUser.ascx.vb"
Inherits
=
"TEST.loginUser"
%>
02.
<%@ Import
Namespace
=
"System.Data"
%>
03.
<%@ Import
Namespace
=
"System.Data.SqlClient"
%>
04.
<script runat=
"server"
>
05.
Sub
submit_click(
ByVal
sender
As
Object
,
ByVal
e
As
EventArgs)
06.
Dim
user
As
String
=
Me
.txtuser.Text
07.
Dim
pass
As
String
=
Me
.txtpass.Text
08.
Dim
objCon
As
SqlConnection
09.
Dim
objCmd
As
SqlCommand
10.
Dim
sql
As
String
11.
Dim
strConnection
As
String
= ConfigurationManager.ConnectionStrings(
"strConnection"
).ConnectionString
12.
Dim
intNumRows
As
Integer
13.
Try
14.
sql =
"select count(*) from username where uid = '"
& user &
"' and password = '"
& pass &
"'"
15.
objCon =
New
SqlConnection
16.
With
objCon
17.
.ConnectionString = strConnection
18.
.Open()
19.
End
With
20.
objCmd =
New
SqlCommand
21.
With
objCmd
22.
.Connection = objCon
23.
.CommandText = sql
24.
.CommandType = CommandType.Text
25.
End
With
26.
intNumRows = objCmd.ExecuteScalar
27.
If
intNumRows > 0
Then
28.
Session.Add(
"username"
, user)
29.
Response.Redirect(
"addData.aspx"
)
30.
Else
31.
MsgBox(
"username or password is incorrect !!!"
)
32.
End
If
33.
Catch
ex
As
Exception
34.
MsgBox(ex.message)
35.
End
Try
36.
objCon.Close()
37.
objCon =
Nothing
38.
End
Sub
39.
</script>
40.
<asp:Panel ID=
"PaneLogin"
runat=
"server"
>
41.
<asp:Label ID=
"Label1"
runat=
"server"
Text=
"username: "
Width=
"100px"
></asp:Label>
42.
<asp:TextBox ID=
"txtuser"
runat=
"server"
MaxLength=
"12"
Width=
"200px"
></asp:TextBox>
43.
<asp:RequiredFieldValidator ID=
"checktxtuser"
runat=
"server"
44.
ErrorMessage=
"*Username Require"
ControlToValidate=
"txtuser"
></asp:RequiredFieldValidator>
45.
<br />
46.
<asp:Label ID=
"Label2"
runat=
"server"
Text=
"password: "
Width=
"100px"
></asp:Label>
47.
<asp:TextBox ID=
"txtpass"
runat=
"server"
MaxLength=
"12"
Width=
"200px"
48.
TextMode=
"Password"
></asp:TextBox>
49.
<br />
50.
<asp:Label ID=
"Label3"
runat=
"server"
Text=
""
Width=
"100px"
></asp:Label>
51.
<asp:Button ID=
"btnsubmitLogin"
runat=
"server"
Text=
"Login"
OnClick=
"submit_click"
/>
52.
<br />
53.
<a href=
"start.aspx"
>Register</a>
54.
</asp:Panel>