Results 1 to 10 of 10

Thread: Logins by different users

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2005
    Posts
    27

    Question 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?

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Feb 2005
    Posts
    27

    Re: Logins by different users

    I am new to V so how would I loop through the differents tables?

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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:
    1. rs.movefirst
    2.  do while not rs.eof
    3.  
    4.        if rs!user = textuser.text then exit do
    5.        rs.movenext
    6.  
    7. loop
    8.  
    9. if rs!pass = textpass.text then
    10. ' login good
    11. else 'login bad
    12. 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

  5. #5
    Member neanthedral's Avatar
    Join Date
    Dec 2004
    Posts
    57

    Re: Logins by different users

    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
    ------------------------------------------------------
    "i am neither a psycopath nor ur abnormal demi-god;
    me - i am just an average software engineer...which is far worse ..so beware.. " .NeaNthedraL
    ------------------------------------------------------

  6. #6
    Fanatic Member
    Join Date
    Sep 2004
    Location
    Jakarta, Indonesia
    Posts
    818

    Re: Logins by different users

    doing loop is not an option if u have many user

    try this
    VB Code:
    1. sSQL = SELECT UserPassword FROM tblUser WHERE Username = '" & txtusername.text & "' AND UserPassword = '" & txtPassword.text & "'"
    2. rs.open sSQL, ur_conn, adopenForwardOnly, adLockReadonly
    3. if rs.eof = true and rs.bof =true then
    4.   msgbox "Not Found"
    5. else
    6.   'do ur stuff here
    7. endif
    the method above is prone to SQL injection..so u might want consider using SP or PQ to do it

    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

    1st NF - a table should not contain repeating groups.
    2nd NF - any fields that do not depend fully on the primary key should be moved to another table.
    3rd NF - there should be no dependency between non key fields in same table.
    - E. Petroutsos -


    eRiCk

    A collection of "Laku-abis" Ebook, Permanent Residence

    Access Reserved Words, a Classic Form Bug, Access Limitation, Know run Process and the Lock they hold in, Logging User Activity in MSSQL,
    Kill Database Processes

  7. #7
    Addicted Member
    Join Date
    Aug 2004
    Posts
    176

    Re: Logins by different users

    It seems we missed an important point
    I have an oracle database which has three different tables for three different user each have a username and password.

  8. #8
    Fanatic Member
    Join Date
    Sep 2004
    Location
    Jakarta, Indonesia
    Posts
    818

    Re: Logins by different users

    It seems we missed an important point

    1st NF - a table should not contain repeating groups.
    2nd NF - any fields that do not depend fully on the primary key should be moved to another table.
    3rd NF - there should be no dependency between non key fields in same table.
    - E. Petroutsos -


    eRiCk

    A collection of "Laku-abis" Ebook, Permanent Residence

    Access Reserved Words, a Classic Form Bug, Access Limitation, Know run Process and the Lock they hold in, Logging User Activity in MSSQL,
    Kill Database Processes

  9. #9
    Addicted Member
    Join Date
    Aug 2004
    Posts
    176

    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.

  10. #10
    Fanatic Member
    Join Date
    Sep 2004
    Location
    Jakarta, Indonesia
    Posts
    818

    Re: Logins by different users

    ... 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
    Last edited by erickwidya; Feb 4th, 2005 at 03:14 AM.

    1st NF - a table should not contain repeating groups.
    2nd NF - any fields that do not depend fully on the primary key should be moved to another table.
    3rd NF - there should be no dependency between non key fields in same table.
    - E. Petroutsos -


    eRiCk

    A collection of "Laku-abis" Ebook, Permanent Residence

    Access Reserved Words, a Classic Form Bug, Access Limitation, Know run Process and the Lock they hold in, Logging User Activity in MSSQL,
    Kill Database Processes

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width