1 Replies - 36711 Views - Last Post: 04 May 2008 - 07:49 AM Rate Topic: -----

#1 cpredator   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 08-July 07

Login Form with MS Access

Posted 04 May 2008 - 02:52 AM

hi all, i'm having problem for the admin(manager) verification using the followin codes, i'm codin in VB with MS Access Database.

i hav followin columns in my database:-
ID Autonumber
usename Text
password Text
isManager Yes/No

data inside the database:-
manager manager
staff1 staff1
staff2 staff2

the program could be verify whether the login is a manager or normal staffs.
but it keep giving me the problem as shown in the attachment, scratchin head...

Imports System.Data.OleDb

Module Module1

	Public admin As Boolean  'Use to identify if current user is Administrator

End Module

Public Class StaffLogin

	Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
		username.Clear()
		password.Clear()
	End Sub

	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		Close()
	End Sub

	Private Sub StaffLogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
		'TODO: This line of code loads data into the 'HESDataSet.StaffLogin' table. You can move, or remove it, as needed.
		Me.StaffLoginTableAdapter.Fill(Me.HESDataSet.StaffLogin)

	End Sub

	Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
		Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=C:\Documents and Settings\Antonio\Desktop\Hotel Entertainment System\Hotel Entertainment System\HES.mdb")
		Dim cmd As OleDbCommand = New OleDbCommand("SELECT Username FROM StaffLogin WHERE Username = '" & username.Text & "' AND Password = '" & password.Text & "' ", cn)

		cn.Open()
		Dim dr As OleDbDataReader = cmd.ExecuteReader()
		If (dr.Read() = True) Then
			admin = dr("isManager")
			If (admin = True) Then
				MsgBox("Login Successful, " & username.Text & "!")
			Else
				MsgBox("you are not manager!")
			End If
		Else
			MsgBox("invalid login")
		End If
		cn.Close()

	End Sub
End Class


Attached Image

Is This A Good Question/Topic? 0
  • +

Replies To: Login Form with MS Access

#2 PsychoCoder   User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1663
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Login Form with MS Access

Posted 04 May 2008 - 07:49 AM

Well you are using this line admin = dr("isManager") but in your query you're not returning anything with the name isManager, so you're going to get an error when trying to do this. Also, this is VB.NERT code so Im moving it to that forum.
Was This Post Helpful? 1

Page 1 of 1