Hi.i am sandhya.i want to acces login page hen i gv only user specified userid and pwd .otherthan login page uerid and pwd,it will display error msg.
the code is
Imports System.Data.OleDb
Partial Class Default2
Inherits System.Web.UI.Page
Private Property UserName As Object
Private Property auth As Boolean
Private Property txtPwd As Object
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim connString As String = "Data Source=C:\Users\Administrator\Desktop\login.mdb;Provider=Microsoft.Jet.OleDb.4.0"
Dim qryString As String = "SELECT username, password FROM login;"
Dim objConn As New OleDbConnection(connString)
Dim objCmd As New OleDbCommand(qryString, objConn)
Dim myReader As OleDbDataReader
Try
Dim gotUser As Boolean = False
objConn.Open()
myReader = objCmd.ExecuteReader
While myReader.Read
.. If myReader.Item("username") = UserName.Text Then..
gotUser = True
auth = CheckPwd(myReader.Item("username"), myReader.Item("password"))
End If
End While
If gotUser = False Then
Label3.Text = "You are not authorized for access"
Else
Select Case auth
Case True
FormsAuthentication.RedirectFromLoginPage(UserName.Text, False)
Case Else
Label3.Text = "Incorrect Password"
End Select
End If
Catch ex As Exception
Label3.Text = ex.ToString
Finally
objConn.Close()
End Try
End sub
Public Function CheckPwd(ByVal username As String, ByVal password As String) As Boolean
Dim Authorized As Boolean = False
Dim pwdFromUser As String = txtPwd.Text
If pwdFromUser = password Then
Authorized = True
Else
Authorized = False
End If
Return Authorized
End Function
End Class
at ... line i got the error as
System.NullReferenceException: Object variable or With block variable not set. at Microsoft.VisualBasic.CompilerServices.Symbols.Container..ctor(Object Instance) at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack) at Default2.Button1_Click(Object sender, EventArgs e) in C:\Users\Administrator\Documents\Visual Studio 2010\WebSites\WebSite9\Default2.aspx.vb:line 28
pls help me