Imports System.Data.OleDb
Partial Class _Default
Inherits System.Web.UI.Page
Dim con As New OleDbConnection
Dim cmd As OleDbCommand
Dim dr As OleDbDataReader
Dim sda As New OleDbDataAdapter
Protected Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogin.Click
Try
con.Open()
If Me.Select1.Value = "User" Then
cmd = New OleDbCommand("select * from `USERS` where USERNAME='" & txtUsername.Text & "' and PASSWORD='" & txtPassword.Text & "'", con)
dr = cmd.ExecuteReader
dr.Read()
If txtUsername.Text = dr(8) And txtPassword.Text = dr(9) Then
Response.Redirect("USER.aspx")
End If
End If
If Me.Select1.Value = "Admin" Then
cmd = New OleDbCommand("select * from `ADMINUSERS` where USERNAME='" & txtUsername.Text & "' and PASSWORD='" & txtPassword.Text & "' ", con)
dr = cmd.ExecuteReader
dr.Read()
If txtUsername.Text = dr(8) And txtPassword.Text = dr(9) Then
Response.Redirect("Default.aspx")
End If
End If
Catch ex As Exception
End Try
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
con.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=" & Me.Server.MapPath("EMP.mdb")
End Sub
End Class
A.Venkatesan
Microsoft Certified Professional
Please mark the replies as answers if they help or unmark if not.
If you have any feedback about my replies, please contact venkatmca008@gmail.com
venkatmca008
Participant
1810 Points
341 Posts
Re: connection
Feb 19, 2012 11:20 AM|LINK
hi...my program...use this..
Imports System.Data.OleDb Partial Class _Default Inherits System.Web.UI.Page Dim con As New OleDbConnection Dim cmd As OleDbCommand Dim dr As OleDbDataReader Dim sda As New OleDbDataAdapter Protected Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogin.Click Try con.Open() If Me.Select1.Value = "User" Then cmd = New OleDbCommand("select * from `USERS` where USERNAME='" & txtUsername.Text & "' and PASSWORD='" & txtPassword.Text & "'", con) dr = cmd.ExecuteReader dr.Read() If txtUsername.Text = dr(8) And txtPassword.Text = dr(9) Then Response.Redirect("USER.aspx") End If End If If Me.Select1.Value = "Admin" Then cmd = New OleDbCommand("select * from `ADMINUSERS` where USERNAME='" & txtUsername.Text & "' and PASSWORD='" & txtPassword.Text & "' ", con) dr = cmd.ExecuteReader dr.Read() If txtUsername.Text = dr(8) And txtPassword.Text = dr(9) Then Response.Redirect("Default.aspx") End If End If Catch ex As Exception End Try End Sub Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load con.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=" & Me.Server.MapPath("EMP.mdb") End Sub End ClassMicrosoft Certified Professional
Please mark the replies as answers if they help or unmark if not.
If you have any feedback about my replies, please contact venkatmca008@gmail.com