Iowa Web Network

Just another WordPress site
  • Home
  • ASP.NET
  • Classic ASP
  • CSS
  • Contact
  • .NET 4.0
  • Applications
    • Access
    • ASP.NET
      • Controls
      • Date and Time Format
      • Email
      • Survey Form
      • Validation Controls
      • VS2010
    • Encryption
    • jQuery
    • System Info
  • Articles
  • Classic ASP
  • Classified
  • Css
  • Error
    • application error
    • application pool
    • system error
  • HTML
  • Images
  • JavaScript
  • MS SQL
  • Networking
    • Wi-Fi
  • SQL
  • UNC
  • VS2012
Home » Applications » Login

Login

December 27, 2010 - Posted in Applications, ASP.NET

~ Access db backend ~

Web.config

<system.web>

<authentication mode=”Forms”>
<forms loginUrl=”Login.aspx” timeout=”2880″/>
</authentication>

</system.web>

Login.aspx

<form id=”form1″ runat=”server” >
<table >
<tr>
<td colspan=”2″><b>Login Form</b></td>
</tr>
<tr>
<td>Intranet Username: </td><td style=”color: Red;” >
<asp:TextBox ID=”usn” runat=”server”  TextMode=”password” />
<asp:RequiredFieldValidator ID=”ReqVal_1″ controltovalidate=”usn”
validationgroup=”Login1″ runat=”server” ErrorMessage=” ? ” >
</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>Teller #: </td><td style=”color: Red;” ><asp:TextBox ID=”pwd” runat=”server” TextMode=”password” />
<asp:RequiredFieldValidator ID=”ReqVal_2″ controltovalidate=”pwd”
validationgroup=”Login1″ runat=”server” ErrorMessage=” ? ” >
</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator runat=”server” ErrorMessage=”Numbers only.”
ControlToValidate=”pwd” validationgroup=”Login1″ ValidationExpression=”^\d+$” /></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td></td>
<td ><asp:Label ID=”Label1″ runat=”server” /><br />
<asp:Label ID=”Label2″ runat=”server” /></td>
</tr>
<tr>
<td></td><td ><asp:Button ID=”submit” runat=”server” Text=”submit”
CausesValitdation=”True” ValidationGroup=”Login1″ />

</td>
</tr>
</table>
</form>

Loginn.aspx.vb

Imports System.IO
Imports System.Data.OleDb
Imports System.Web.UI.WebControls.Button
Imports System.Web.UI.WebControls.TextBox
Imports System.Web.SessionState
Imports System.Web.Security

Partial Class Login
Inherits System.Web.UI.Page

Protected Sub submit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles submit.Click
‘defining variables/controls
Dim usn As TextBox
Dim pwd As TextBox

‘binding controls
usn = submit.FindControl(“usn”)
pwd = submit.FindControl(“pwd”)

‘/ access db connection – MS Access 2007/10 driver * you can define your own sql connection
Dim ConnDB As New OleDbConnection(“Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|/myDB.mdb;Persist Security Info=True”)
Dim cmd As New OleDbCommand(“SELECT * FROM Login WHERE (username = ‘” & usn.Text.ToString() & “‘) AND (password = ” & pwd.Text.ToString() & “);”, ConnDB)
Dim reader As OleDbDataReader

Try

‘/ open connection
cmd.Connection.Open()
reader = cmd.ExecuteReader()
If reader.Read() Then
Label1.Text = (“<font color=’green’>You are logged in!</font>”)
Session(“Name”) = reader(1).ToString()
Response.Redirect(“MySecurePage.aspx”)
Else
Label1.Text = (“<font color=’red’>Wrong Username or Password!</font>”)
End If

cmd.Connection.Close()

‘/ end
Catch ex As Exception
Label2.Text = “ERROR: ” & ex.Message.ToString()     ‘/ in case of error

End Try

End Sub

End Class

Tags: ASP.NET, Login, Programming, Visual Studio

« Login
Login »
  • Posts by Date

    December 2010
    M T W T F S S
     12345
    6789101112
    13141516171819
    20212223242526
    2728293031  
        Jan »
  • Recent Posts

    • ASP.NET (C#) – Session Info – Count Clicks
    • ASP.NET (VB) File Upload with Delete
    • ASP.NET (VB) – Multiple Files Upload
    • VB.NET – User Impersonation
    • VB.NET – OleDbConnection Properties
  • Admin Corner

    Login
    Email
  • Post Tags

    Access array ASP.NET bulleted button Calendar characters Classic ASP Colorbox Container.DataItem content Controls Count CSS Date datepicker Email Encryption file Format Form Validation Gridview HTML image Javascript jQuery list Login monitor OleDbConnection Parameters Programming Record update redirect security select session SQL Time total upload uptime Visual Studio web design website

Iowa Web Network is proudly powered by WordPress