ok nasiel som tento code vyzera ze funguje ale pls skontroluj ci tam neni daka chyba
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script language="VB" runat="server">
Sub btnLogin_OnClick(Src As Object, E As EventArgs)
Dim myConnection As OleDbConnection
Dim myCommand As OleDbCommand
Dim intUserCount As Integer
Dim strSQL As String
strSQL = "SELECT COUNT(*) FROM tblLoginInfo " _
& "WHERE username='" & Replace(txtUsername.Text, "'", "''") & "' " _
& "AND password='" & Replace(txtPassword.Text, "'", "''") & "';"
myConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " _
& "Data Source=" & Server.MapPath("login.mdb") & ";")
myCommand = New OleDbCommand(strSQL, myConnection)
myConnection.Open()
intUserCount = myCommand.ExecuteScalar()
myConnection.Close()
'Response.Write(intUserCount)
If intUserCount > 0 Then
lblInvalid.Text = ""
FormsAuthentication.SetAuthCookie(txtUsername.Text, True)
Response.Redirect("login_db-protected.aspx")
Else
lblInvalid.Text = "Sorry... try again..."
End If
End Sub
</script>
<html>
<head>
<title>ASP.NET Login (Database-Driven) Sample</title>
</head>
<body>
<form runat="server">
Username: <asp:TextBox id="txtUsername" runat="server" /><br />
Password: <asp:TextBox id="txtPassword" TextMode="password" runat="server" /><br />
<br />
<asp:Button id="btnLogin" runat="server"
text="Login" OnClick="btnLogin_OnClick"
/>
<asp:Label ID="lblinvalid" runat="server" Text="Label"></asp:Label>
</form>
</body>
</html>
dik a este tento code znamena ze ked vytvorim dalsiu stranku uz tam bude prihlaseny
FormsAuthentication.SetAuthCookie(txtUsername.Text, True)
|