+ Reply to Thread
Results 1 to 5 of 5

Thread: How to create a Log In form that uses a Remote Database

  1. #1
    Join Date
    Nov 2006
    Location
    Kosovo
    Posts
    448
    Rep Power
    28

    How to create a Log In form that uses a Remote Database

    To do this your users will need MySQL Connector/ODBC 3.51, a little driver needed to establish your connection. Then you will use ADO(ActiveX Data Objects) to surf in the database.

    How to do this?
    First the program will look for the user. If the user doesn’t exist it shows the error. If the user exists it will move to that record and check if the passwords are the same. If the second condition is true then it will show the LOGGED form. To secure passwords I suggest you using the MD5 Class to convert passwords in Base64 Hashes.

    How to code this?
    First add the following code in a module to simplify things:

    Code:
    Option Explicit
    Dim conn As ADODB.Connection
    Dim MySQL1 As ADODB.Recordset
    Dim username As String
    Dim passwd As String
    Dim serverIP As String
    Dim db As String
    
    Public Function connectMysql(username As String, passwd As String, serverIP As String, db As String, conn As ADODB.Connection, MySQL1 As ADODB.Recordset)
       Set conn = New ADODB.Connection
       Set MySQL1 = New ADODB.Recordset
       conn.CursorLocation = adUseClient
       conn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=" & serverIP & ";UID=" & username & ";PWD=" & passwd & ";DATABASE=" & db & ";"
        On Error GoTo Err:
       conn.Open
        On Error GoTo Err:
       
       Exit Function
    Err:
       MsgBox "Error connecting to the Server, try again please!    ", vbCritical
    End Function
    Now go to the Project’s References Dialog(Click the “Project” menu then “References”) and find “Microsoft ActiveX Data Objects 2.7 Library”, tick it and click OK. Create your login form and declare the following variables:

    Code:
    Option Explicit
    Dim conn As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim username As String
    Dim passwd As String
    Dim serverIP As String
    Dim db As String
    Dim ssql As String
    Add the following code to the Form_Load() sub:

    Code:
    Call connectMysql("UserHere", "PassHere", "ServerNameHere", "DBNameHere", conn, rs)
    
    ssql = "SELECT * FROM TableNameHere"
    rs.Open ssql, conn, adOpenStatic, adLockOptimistic
    You MUST change UserHere with your MySQL Username, PassHere with your MySQL User Password, ServerNameHere with your Server’s IP Address or domain, DBNameHere with your Database name and in the next line TableNameHere with your table in wich the users are stored.

    In the table there must be 2 fields “User” and “Pass”. Add users and their passwords on this table and you will be able to log with them immediately.

    Now to the “LogIn” button add the following code:

    Code:
    If txtUser = "" Then
        MsgBox "Please enter the Username!  ", vbCritical
    Else
       
        rs.MoveFirst
        rs.Find "[User] like '*" & txtUser & "*'"
        
        If rs.EOF Then
            MsgBox "The Username that you have entered doesn't exist in the database!  ", vbCritical
        Else
            If txtPass = rs![Pass] Then
                LOGGED.Show
            Else
                MsgBox "The password is incorrect, please retype it!   ", vbCritical
            End If
        End If
    
    End If
    If you still have trouble understanding something, download the attachment and study it.

    PS: You can run your MySQL Server on your PC if you have a public IP or if your clients are in LAN and don’t forget to install the MySQL Connector/ODBC 3.51 Driver to the clients.

    Wish you all the best,
    Dren
    Attached Files Attached Files

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    Join Date
    Aug 2006
    Posts
    11,209
    Blog Entries
    6
    Rep Power
    101

    Re: How to create a Log In form that uses a Remote Database

    Didn't try the software. But seems a promising.. and I might use it myself sometime.

    +rep to you!

  4. #3
    woddlez is offline Newbie
    Join Date
    Aug 2008
    Posts
    1
    Rep Power
    0

    Re: How to create a Log In form that uses a Remote Database

    Awesome O_o

    Btw im probably gonna be a leecher, because all i need is a few examples to borrow, i will add credits btw, and ill also +rep you because this is awesome lol

    -Woddles

  5. #4
    OliWilding is offline Newbie
    Join Date
    Feb 2009
    Posts
    4
    Rep Power
    0

    Re: How to create a Log In form that uses a Remote Database

    This should help with my A level coursework nicely

  6. #5
    Join Date
    Sep 2008
    Location
    Kosovo
    Posts
    4,032
    Rep Power
    44

    Re: How to create a Log In form that uses a Remote Database

    haven't seen this one .. +rep to you bro ..

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Rails 3 remote form processing as HTML
    By aguswgs in forum Ruby Programming
    Replies: 0
    Last Post: 04-14-2011, 08:13 PM
  2. Connecting to a remote access database
    By mucalo in forum PHP Development
    Replies: 3
    Last Post: 04-22-2009, 07:30 AM
  3. How would I create a database through SSH?
    By blkobswg in forum Database & Database Programming
    Replies: 5
    Last Post: 04-18-2009, 01:19 PM
  4. create a form with a button with $post
    By achi in forum PHP Development
    Replies: 6
    Last Post: 03-09-2009, 10:08 AM
  5. Create database from Visual C#
    By broncoslb in forum Database & Database Programming
    Replies: 0
    Last Post: 03-24-2008, 05:21 PM

Tags for this Thread

Bookmarks

Posting Permissions

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