Results 1 to 6 of 6

Thread: Check if data is correct. I have a Password problem.

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2003
    Posts
    38

    Check if data is correct. I have a Password problem.

    Hi,
    I have this program that users have to login. using a database.
    the problem is i don't know how to make the program to see if the password matches the username or even if the username and password exist.
    you know what i mean.........
    can you please help me out with this. is there a simple sample code you can give me so i could play around with it.
    thankyou very very much.
    I hope you can help.

  2. #2
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    is the application created in VB or Asp or something else?
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  3. #3

    Thread Starter
    Member
    Join Date
    Apr 2003
    Posts
    38
    well its obvious that i am using
    VISUAL BASIC .
    do you no what to do?

  4. #4
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    mmm....k, what type of database are you using? Don't assume we know what you are using. i.e. vb, asp. Try to provide as much information as possible in your original post, that way we don't have to continue to ask questions.

    People post questions hear relating to all kinds of apps (VB, C++, Java, ASP, PHP) as well as all kinds of databases (Access, MS SQL, PostgresSQL, Oracle.) So being clear about what programming or database you are using in the beginning will save time.
    Last edited by Memnoch1207; Apr 4th, 2003 at 01:34 PM.
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  5. #5

    Thread Starter
    Member
    Join Date
    Apr 2003
    Posts
    38
    hi,
    visual basic 6
    microsoft access 2002 ( but i can convert to 97 database too )
    please help.
    thanks

  6. #6
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    Code:
    'Connection to database
    conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
               "Data Source=c:\pathToDB\myDb.mdb;" & _ 
               "User Id=yourUserid;" & _
               "Password=yourPassword"
    
    Set adoprimaryrs = New Recordset 
    '2 fields in database table username and password
    adoprimaryrs.Open "SELECT * from tableName", conn, adOpenStatic, adLockOptimistic 
    
    '2 textboxes on the form txtUsername and txtPassword
    
    If txtUsername.Text = Trim(adoprimaryrs.Fields("userName")) And txtPassword.Text = Trim(adoprimaryrs.Fields("password")) Then 
    LoginSucceeded = True 
    Me.Hide 
    FormMain.Show 
    Else 
    MsgBox "Invalid username/Password, try again!", , "Login" 
    txtUsername.SetFocus 
    SendKeys "{Home}+{End}" 
    End If
    or
    Code:
    set adoPrimaryRs = "SELECT * FROM tableName WHERE Username = '" & txtUsername.Text & "'
    
    if(adoPrimaryRs.RecordCount = 1) then
       LoginSucceeded = True
       Me.Hide
       FormMain.Show
    else
       MsgBox "Invalid username/Password, try again!", , "Login"
       txtUsername.SetFocus
       SendKeys "{Home}+{End}"
    end if
    Last edited by Memnoch1207; Apr 4th, 2003 at 02:58 PM.
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

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