i am new in ASP.NET....!
and i want to create login page in ASP.NET...!
i download a code from a tutorial website of ASP.NET
but i have lots of problem when i modified the code...!
<%@ Page Language="VB" %>
<%@ import namespace="System.Data" %>
<%@ import namespace="System.Data.OleDb" %>
<script runat="server">
Public Sub Login_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim userId As Integer
Dim reader As OleDbDataReader
'Dim connectionString = _
'ConfigurationSettings.ConnectionStrings("MyConnectionString")
'Dim conn As New SqlConnection(connectionString)
'Dim command As New SqlCommand("dbo.Authenticate", conn)
'my conncection
Dim strConnection As String = "Provider=Microsoft.Jet.OleDb.4.0;" & _
"data source=E:\asadaspdotnet\nwind.mdb;"
Dim objConnection As New OleDbConnection(strConnection)
Dim command As New OleDbCommand("login.Authenticate", objConnection)
' Set the command type to stored procedure
command.CommandType = CommandType.StoredProcedure
' Set @Username and @Password
command.Parameters.Add("@Username", _
OleDbType.Char, 256).Value = Username.Text
command.Parameters.Add("@Password", _
OleDbType.Char, 256).Value = Password.Text
' Open the connection and execute the reader
objConnection.Open()
' i have error at this point
reader = command.ExecuteReader()
' Read the value we're looking for
reader.Read()
userId = Integer.Parse(reader("UserId"))
' Close connections
reader.Close()
objConnection.Close()
' Did we find a user?
If (userId > 0) Then
FormsAuthentication.RedirectFromLoginPage(Username.Text, _
False)
Else
Status.Text = "Invalid Credentials: Please try again"
End If
End Sub
</script>
<html>
<body style="FONT-FAMILY: Verdana">
<H1>Enter your username/password</H1>
<form id="Form1" runat="server">
Username: <asp:textbox id="Username" runat="server" />
<br>
Password: <asp:textbox id="Password" runat="server" />
<p>
<asp:button id="Button1"
text="Check if Member is Valid"
onclick="Login_Click" runat="server"/>
</form>
<font color="red" size="6">
<asp:label id="Status" runat="server"/>
</font>
</body>
</html>
if u find any error then sove it
Enter your message below
Sign in or Join us (it's free).