vb.net - Visual basic database login: manager and admin logins -
i have code open form if login credentials matches database. dont know how add separate login manager. in database made column yes/no called ismanager , checked 1 of users cant seem if checked , open different form. can please improve code make change?
public class login public function login() 'save database file in u:\my documents\visual studio 2008\projects\sequenceselectionrepetition\sequenceselectionrepetition\bin\debug 'right-click sequenceselectionrepetition solution explorer , select add reference 'choose com , choose microsoft activex daba objects 2.5 library dim dbconn new adodb.connection dim users new adodb.recordset dim username string dim userdb string dim passdb string dim userfound boolean dbconn.open("provider = microsoft.ace.oledb.12.0;" & "data source = '" & application.startuppath & "\capsule staff.accdb'") users.open("credentials", dbconn, adodb.cursortypeenum.adopenstatic, adodb.locktypeenum.adlockoptimistic) userfound = false username = "id = '" & txtusername.text & "'" users.find(username) if users.bof = false , users.eof = false userdb = users.fields("id").value.tostring passdb = users.fields("password").value.tostring if userdb <> txtusername.text users.close() dbconn.close() return false else userfound = true if passdb = txtpassword.text users.close() dbconn.close() return true else users.close() dbconn.close() return false end if end if end if 'user not found users.close() dbconn.close() return false end function private sub button1_click(byval sender system.object, byval e system.eventargs) handles button1.click if login() = true messagebox.show("manager login successful") manager.show() me.hide() txtusername.clear() txtpassword.clear() elseif login() = true messagebox.show("login successful") register.show() me.hide() txtusername.clear() txtpassword.clear() else messagebox.show("error:unable login, refer user manual more information") txtusername.clear() txtpassword.clear() end if end sub
end class
Comments
Post a Comment