14 Replies - 20787 Views - Last Post: 31 March 2011 - 09:33 PM Rate Topic: -----

#1 ermias2000  Icon User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 8
  • Joined: 26-March 11

Creating A Login Form That Checks Against The Database

Posted 26 March 2011 - 06:09 AM

Hello and HELP!

I am a near or a complete newbie to vb 6.0 or any versions. ok..I'm assigned to create a login form with two textbox - username and password. Plus two command buttons, to enter or reset.

So..how do i connect my form to my access database so that it would check against the database for the correct username and password before allowing the user to login? I have search through the posts in the forum and on the web for days but failed to find any or failed to understand it. Sorry for this newbish question because i am new..

Thanks.

Is This A Good Question/Topic? 0
  • +

Replies To: Creating A Login Form That Checks Against The Database

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6058
  • View blog
  • Posts: 23,495
  • Joined: 23-August 08

Re: Creating A Login Form That Checks Against The Database

Posted 26 March 2011 - 06:16 AM

Have you looked through our tutorials?
Was This Post Helpful? 0
  • +
  • -

#3 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: Creating A Login Form That Checks Against The Database

Posted 27 March 2011 - 08:27 PM

This question gets asked about twice a week. :)
Was This Post Helpful? 0
  • +
  • -

#4 ermias2000  Icon User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 8
  • Joined: 26-March 11

Re: Creating A Login Form That Checks Against The Database

Posted 30 March 2011 - 07:53 AM

I am a near to compelet mini-application using vb 6.0 with the helpe of microsoft acsess database(mdb) format 2002 to 2003 ok..I'm assigned to create a login form with two textbox - userid and password. Plus two command buttons, to login and cance.

So..how do i connect my form to my access database named ERPAY and the Table name that have filed name of user id and Password is TUSE. and i have many userid with password in each fialed( i.e userid ermi and password 1234 )so that it would check against the database for the correct userid and password before allowing the user to login? also i need hint of cods how to add other users other than the one that i have in the database using forms. I have search through the posts in the forum and on the web for days but failed to find any or failed to understand it. Sorry for this newbish question because i am new..

Thanks.

This post has been edited by ermias2000: 30 March 2011 - 08:01 AM

Was This Post Helpful? 0
  • +
  • -

#5 ermias2000  Icon User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 8
  • Joined: 26-March 11

Re: Creating A Login Form That Checks Against The Database

Posted 30 March 2011 - 07:58 AM

I am a near to compelet mini-application using vb 6.0 with the helpe of microsoft acsess database(mdb) format 2002 to 2003 ok..I'm assigned to create a login form with two textbox - userid and password. Plus two command buttons, to login and cance.

So..how do i connect my form to my access database named ERPAY and the Table name that have filed name of user id and Password is TUSE. and i have many userid with password in each fialed( i.e userid ermi and password 1234 )so that it would check against the database for the correct userid and password before allowing the user to login? also i need hint of cods how to add other users other than the one that i have in the database using forms. I have search through the posts in the forum and on the web for days but failed to find any or failed to understand it. Sorry for this newbish question because i am new..

Thanks.
Was This Post Helpful? -1
  • +
  • -

#6 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9094
  • View blog
  • Posts: 34,148
  • Joined: 12-June 08

Re: Creating A Login Form That Checks Against The Database

Posted 30 March 2011 - 08:14 AM

This is a really common assignment and I am somewhat shocked you couldn't find anything on the topic.

Regarding how to connect to access check out this tutorial. Sure it's for SQL, but the concepts are the same:
http://www.dreaminco...ase-using-adodb

How to check against the database - well that takes a SQL SELECT statement. The basics of that can be found here:
http://msdn.microsof...y/ms189499.aspx
http://msdn.microsof...y/ms187731.aspx

Adding other users would require a form to use the SQL statement INSERT. Info on that would be found here:
http://msdn.microsof...y/ms174335.aspx

While the SQL statements point to MSSQL the concept is the same.

DIC isn't a code writing service. We can help you, but you need to do the heavy lifting yourself! Let us know how it goes!
Was This Post Helpful? 0
  • +
  • -

#7 ermias2000  Icon User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 8
  • Joined: 26-March 11

Re: Creating A Login Form That Checks Against The Database

Posted 30 March 2011 - 08:58 AM

hey this is not assyinment as u said. but am doind this application for my caffeies payroll system okey pls give some hint
Was This Post Helpful? -2
  • +
  • -

#8 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9094
  • View blog
  • Posts: 34,148
  • Joined: 12-June 08

Re: Creating A Login Form That Checks Against The Database

Posted 30 March 2011 - 09:02 AM

I am not sure what "caffeies" is, but I did gave you a whole lot of hints and direction! DIC's not about just handing out code you know! The majority of effort should come from you!
Was This Post Helpful? 0
  • +
  • -

#9 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6058
  • View blog
  • Posts: 23,495
  • Joined: 23-August 08

Re: Creating A Login Form That Checks Against The Database

Posted 30 March 2011 - 09:40 AM

Merged duplicate topics. Do NOT create e new topic on the subject as one you already have.
Was This Post Helpful? 0
  • +
  • -

#10 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: Creating A Login Form That Checks Against The Database

Posted 30 March 2011 - 01:32 PM

View Postermias2000, on 30 March 2011 - 03:58 PM, said:

I am a near to compelet mini-application using vb 6.0 with the helpe of microsoft acsess database(mdb) format 2002 to 2003 ok..I'm assigned to create a login form with two textbox - userid and password. Plus two command buttons, to login and cance.

So..how do i connect my form to my access database named ERPAY and the Table name that have filed name of user id and Password is TUSE. and i have many userid with password in each fialed( i.e userid ermi and password 1234 )so that it would check against the database for the correct userid and password before allowing the user to login? also i need hint of cods how to add other users other than the one that i have in the database using forms. I have search through the posts in the forum and on the web for days but failed to find any or failed to understand it. Sorry for this newbish question because i am new..

Thanks.

You say you've nearly completed this application, but you haven't connected to your database, and don't know how to access values in the database on a form. You say you've been searching for days and still can't find the information you're looking for, or perhaps can't understand. If you can't find the information, you're not looking. If you can't understand what you have found, then you haven't been able to nearly complete a mini-application using access either.

You say you're working for a company and have this assignment, and yet you publish a database name, a userid and a password on the internet for anyone to see. In other words, you don't seem to be at all concerned about your company getting hacked.

In other words, you're attempting to present yourself as someone who has put a great deal of work in to a job assignment at your company and needs a bit of help to finish his work assignment, when in fact, you are doing this as a classroom assignment, haven't done a thing, and are hoping that you can b. s. someone into doing your work for you.

When modi gave you everything you need to figure this out for yourself, you tried throwing out another fishing line to see if someone else would write it for you. :no: We're used to college kids coming in here and trying to trick us into doing their assignments for them, you know?

Four posts, and you're already wearing out your welcome. Must be some sort of record...

This post has been edited by BobRodes: 30 March 2011 - 01:47 PM

Was This Post Helpful? 1
  • +
  • -

#11 ermias2000  Icon User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 8
  • Joined: 26-March 11

Re: Creating A Login Form That Checks Against The Database

Posted 31 March 2011 - 12:26 AM

hey bosse am try it very well by my self from the information that i get from different sources but am not some how meet my need but i test useing the given user id and password but i need from the databes that i inform u before. also i confirm u the information zat i give is simply example not real okey b/c of the risk you said. by theway look at the code that i use and fix for me pls. am very shour it not assignments its for my own company b/c my company doing every thing manualy so i need to use computer.


Private Sub cmdlogon_Click()
txtUserName.SetFocus
If txtUserName = "ermi" And txtPassword = "1234" Then
   MsgBox "Access Granted", vbInformation, "cd shop"
   MsgBox "welcom", vbInformation, "cd shop"
   frmLogin.Cls
   frmUSERREG.Show
ElseIf txtUserName = "mek" And txtPassword = "1222" Then
   MsgBox "Access Granted", vbInformation, "cd shop"
   MsgBox "welcom", vbInformation, "cd shop"
   frmLogin.Cls
   frmUSERREG.Show
ElseIf txtUserName = "sa" And txtPassword = "cmis" Then
   MsgBox "Access Granted", vbInformation, "cd shop"
   MsgBox "welcom", vbInformation, "cd shop"
   frmLogin.Cls
   frmuseridentification.Show
Else
   MsgBox "plsese re-enter your username and password."
     
End If
End Sub



but i need to link users from the database

This post has been edited by modi123_1: 31 March 2011 - 06:49 AM
Reason for edit:: please use code tags

Was This Post Helpful? 0
  • +
  • -

#12 ermias2000  Icon User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 8
  • Joined: 26-March 11

Re: Creating A Login Form That Checks Against The Database

Posted 31 March 2011 - 01:02 AM

also i get this message
data error event hit err: ODBC -- connection to 'ERPAY' failed
Was This Post Helpful? 0
  • +
  • -

#13 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9094
  • View blog
  • Posts: 34,148
  • Joined: 12-June 08

Re: Creating A Login Form That Checks Against The Database

Posted 31 March 2011 - 06:59 AM

Quote

look at the code that i use and fix for me pls.

Man you know that's not how we work here. We are not code fixers, writers, or what not. We help and give advice in our areas of specialties.

Your error - what does your code like trying to connect to your database?
Was This Post Helpful? 0
  • +
  • -

#14 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: Creating A Login Form That Checks Against The Database

Posted 31 March 2011 - 01:41 PM

Ok, maybe you used the word assign because English isn't your first language, instead of because someone assigned this job to you. I'll assume you are speaking truly.

So, what we want to know is what you have done to try to connect to the database?

However, I will give you a bit of advice. Any code that's returning ODBC errors needs to be discarded, and you need instead to use ADO objects. I would start there. Make an ADO Connection, then make a Recordset that uses the Connection, then read the Recordset. And don't ask me to write it for you, please.
Was This Post Helpful? 0
  • +
  • -

#15 everzcool4  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 24-November 09

Re: Creating A Login Form That Checks Against The Database

Posted 31 March 2011 - 09:33 PM

Imagine you have two textboxes in the form (txtUserName and txtPassword) and the access database name is Data.mdb

Private Sub cmdOk_Click()
Dim db_file As String
Dim statement As String
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset

    ' Open the database.
    db_file = App.Path
    If Right$(db_file, 1) <> "\" Then db_file = db_file & "\"
    db_file = db_file & "data.mdb"

    ' Open a connection.
    Set conn = New ADODB.Connection
    conn.ConnectionString = _
        "Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=" & db_file & ";" & _
        "Persist Security Info=False"
    conn.Open

    ' Look up the user name/password.
    statement = "SELECT COUNT (*) FROM Users WHERE " & _
        "UserName='" & Replace(txtUserName.Text, "'", "''") & "' AND " & _
        "Password='" & Replace(txtPassword.Text, "'", "''") & "'"
    Set rs = conn.Execute(statement)

    ' See if we got anything.
    If CLng(rs.Fields(0)) < 1 Then
        ' There is no match.
        ' Do not allow the login.
        Unload Me
        MsgBox "Invalid user name/password."
    Else
        ' There is a match.
        ' Display the program's main form.
        Form1.Show
        Unload Me
    End If

    rs.Close
    conn.Close
End Sub



I think this may help u.

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1