Hello guys, first of all I would like to say my thanks to all for your help. Now I am facing another problem. My Instructor wanted me to use Microsoft SQL Server 2005. The problem is I don't know how to use it please help me.
Here is my trial code:
<%@ Page Language="VB" Debug="true" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="System.Web.UI" %>
<script language="VB" runat="server">
Sub btnLogin_OnClick(Src As Object, E As EventArgs)
Dim strSQL As String
Dim myCommand As OleDbCommand
Dim strUserURL As String
Using connection As New OleDbConnection("datasource1")
strSQL = "SELECT * FROM [Admin] " _
& "WHERE LogName='" & Replace(txtUsername.Text, "'", "''") & "' " _
& "AND LogPass='" & Replace(txtPassword.Text, "'", "''") & "'"
myCommand = New OleDbCommand(strSQL, connection)
connection.Open()
strUserURL = myCommand.ExecuteScalar()
connection.Close()
If strUserURL <> "" Then
lblInvalid.Text = ""
FormsAuthentication.SetAuthCookie(txtUsername.Text, True)
Response.Redirect("bob.aspx")
Else
lblInvalid.Text = "Sorry... try again..."
End If
End Using
End Sub
</script>
<html>
<head>
<title>ASP.NET Login</title>
</head>
<body>
<h2>Please Login:</h2>
<p>
<asp:Label id="lblInvalid" runat="server" />
</p>
<form runat="server">
Username: <asp:TextBox id="txtUsername" runat="server" /><br />
Password: <asp:TextBox id="txtPassword" TextMode="password" runat="server" Width="155px" /><br />
<br />
position:
<asp:TextBox id="items" runat="server" /><br />
<br />
<br />
<asp:Button id="btnLogin" runat="server"
text="Login" OnClick="btnLogin_OnClick" Width="221px"
/>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TestSQLConnectionString %>"
SelectCommand="SELECT * FROM [Admin]" OnSelecting="SqlDataSource1_Selecting"></asp:SqlDataSource>
</form>
</body>
</html>
Here is the web.config:
="1.0"="utf-8"
<configuration>
<system.web>
<authentication mode="Forms">
<forms name="ASP101SampleAuth" loginUrl="login_db_nav.aspx" />
</authentication>
</system.web>
<location path="bob.aspx">
<system.web>
<authorization>
<allow users="*" />
<deny users="none" />
</authorization>
</system.web>
</location>
</configuration>
Now here is the error I'm trying to debug:
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30456: 'SqlDataSource1_Selecting' is not a member of 'ASP.login_db_nav_aspx'.
Source Error:
Line 57: text="Login" OnClick="btnLogin_OnClick" Width="221px"
Line 58: />
Line 59: <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TestSQLConnectionString %>"
Line 60: SelectCommand="SELECT * FROM [Admin]" OnSelecting="SqlDataSource1_Selecting"></asp:SqlDataSource>
Line 61: </form>
Source File: C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx Line: 59
Please help me.. I don't know where I got it wrong..