Logins by different users
Dear all,
I am trying to create a login for different users to have access to certain forms in vb6 I have an oracle database which has three different tables for three different user each have a username and password.
the code that is working for one user is below
If rs.EOF <> True Then
If rs!password = Text2.Text Then
Pass = Text2.Text
Unload Me
form1.Show
else
msg
the rs is the select query selecting the username and password from one table where its the username = text1
Hope some1 can help?
Re: Logins by different users
you only query the same record for all users, you would need to loop through the record set to find if that password matched the user name in any record
rgds pete
Re: Logins by different users
I am new to V so how would I loop through the differents tables?
Re: Logins by different users
it looks to me that you are using ADO and i am just changing to that now, so this may not be right
VB Code:
rs.movefirst
do while not rs.eof
if rs!user = textuser.text then exit do
rs.movenext
loop
if rs!pass = textpass.text then
' login good
else 'login bad
end if
this isn't quite right because if it gets to the last record with out matching user it will still look for a password
rgds pete
Re: Logins by different users
Quote:
this isn't quite right because if it gets to the last record with out matching user it will still look for a password
we can put the processing logic inside the rs loop itself..;)
dim passfound as boolean
passfound=false
rs.movefirst
do while not rs.eof
if rs!user = textuser.text then
if rs!pass = textpass.text then
' login good
passfound =true
else 'login bad exit do
end if
rs.movenext
loop
if passfound=false
msgbox "enter correct passwd"
else
<ur processing here>
endif
thnx
nean
Re: Logins by different users
doing loop is not an option if u have many user
try this
VB Code:
sSQL = SELECT UserPassword FROM tblUser WHERE Username = '" & txtusername.text & "' AND UserPassword = '" & txtPassword.text & "'"
rs.open sSQL, ur_conn, adopenForwardOnly, adLockReadonly
if rs.eof = true and rs.bof =true then
msgbox "Not Found"
else
'do ur stuff here
endif
the method above is prone to SQL injection..so u might want consider using SP or PQ to do it
Quote:
I am trying to create a login for different users to have access to certain forms in vb6
hmm maybe u required Level field at user Table? so if level user is '1' or '2' then u can make it 'direct' to certain form
hope it can help
Re: Logins by different users
It seems we missed an important point
Quote:
I have an oracle database which has three different tables for three different user each have a username and password.
Re: Logins by different users
Quote:
It seems we missed an important point
:ehh: :confused:
Re: Logins by different users
Erick, may be I can't comprehend but he wrote "three different tables for three different users" while your query assumes there to be a single table tblUser.
Re: Logins by different users
Quote:
... how would I loop through the differents tables?
miss read this..not sure about this one..
flair guess u right..my assumption is too fast ;)