Making a Log in Screen (VB6)-VBForums
Results 1 to 9 of 9

Thread: Making a Log in Screen (VB6)

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2009
    Posts
    14

    Making a Log in Screen (VB6)

    Hey Guys,
    Im having problems, Im making a piece of Accounting software using Visual Basic6 Enterprise Edition. My first problem is, I have no idea whatsoever as how to make a login/register user screen. I want this information to be saved into a microsoft access file, but I have no idea how to make the ADO/SQL statements or whatever Im meant to be using.

    If anyone could run me through a step by step approach on how to make this connection and the code that you put behind the buttons, I would greatly appreciate it.

    I've been searching the net for hours on end for a solution, but none seem to suit my purpose Thanks again

    ~Edocsil

  2. #2
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,531

    Re: Making a Log in Screen (VB6)

    Add a form to your application. When you get the options of choosing which type of form to add, you will find one of them is "Login". Add that one. It has most of the code and UI of login screen.
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog • 101 LINQ Samples • JSON Validator • XML Schema Validator • "How Do I" videos on MSDN • VB.NET and C# Comparison • Good Coding Practices • VBForums Reputation Saver • String Enum • Super Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  3. #3
    Addicted Member
    Join Date
    Mar 2008
    Posts
    143

    Re: Making a Log in Screen (VB6)

    hi,
    in the project explorer right click and choose Add->forms a set of forms template will be shown to you choose login dialog a new form will be added to your project, in the db create a table called user or any name , typically the fields must be uid, uname, password put some data into it by entering directly or create a new form to accept inputs from the gui and stores it in db. now in the login form use the select query to find the match between the entered userid and pwd with your db if so redirect to next form or else display login error message
    hth

  4. #4

    Thread Starter
    New Member
    Join Date
    Apr 2009
    Posts
    14

    Re: Making a Log in Screen (VB6)

    Thanks for your help guys,I think everything is going ok now, Im still working on the connection between my Form and Access, but I should be able to manage hopefully. Thanks Again

    ~Edocsil

  5. #5
    Junior Member
    Join Date
    Feb 2009
    Location
    Belfast, UK
    Posts
    27

    Re: Making a Log in Screen (VB6)

    Code:
     
    Option Explicit 
    Public cn As ADODB.Connection 
    Public rs As ADODB.Recordset 
    
    Private Sub Form_Load()
    Me.MousePointer = 11 
    
        Set cn = New ADODB.Connection 
    cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
          "Data Source= D:\TekNI.mdb" 
        cn.Open 
        Set rs = New ADODB.Recordset 
        rs.Open "tbl_security", cn, adOpenKeyset, adLockPessimistic, adCmdTable 
    rs.MoveFirst 
    Me.MousePointer = 0 
    End Sub
    
    Private Sub cmdLogin_Click()
    
    If cn.State = adStateClosed Then
          cn.Open 
    
     End If
     Dim strSQL As String 
    
     strSQL = "Select Count(*) From tbl_security Where Username = '" & Trim(Replace(txtUser.Text, "'", "''")) & "' And Passname = '" & Trim(Replace(txtPass.Text, "'", "''")) & "'" ‘
    
     Dim intCount As Integer 
     intCount = -1 
     Set rs = New ADODB.Recordset
     rs.Open strSQL, cn 
    
     If Not rs.BOF And Not rs.EOF Then
        intCount = rs.Fields(0).Value
     End If 
     rs.Close 
     Set rs = Nothing 
    
     If intCount > 0 Then
    [U]login.Visible = False
       mangementuser.Visible = True
       txtUser.Text = ""
       txtPass.Text = "" U]
     Else
       MsgBox "Invalid User Name and Password." & vbCrLf & _
                  "Please try again." ‘If the username and password don’t match then display this message and don’t continue on’
    
    
    
    End If
    End Sub
    Change the red text to your database name

    Change the blue bit beneath that to the table name

    The sql bit, change the orange bit to table name

    Change the pink bit to your username field you want to read from in the table

    Change the purple bit (txtUser.Text) to the field name where the username is types in, apply this too the next dark green bit and Textpass.Text

    The last bold bit is what form you want to open and what form you need to close.


    THIS IS NOT MY CODE, I GOT HELP FROM ALL THE FORUMS TO PUT IT TOGETHER AND IT WORKS FOR ME.

    You could possibly tidy it up and make it neater but thats it.

    Chris

  6. #6

    Thread Starter
    New Member
    Join Date
    Apr 2009
    Posts
    14

    Re: Making a Log in Screen (VB6)

    Thank you so much for your help mate, I have finally got this bugger of a thing to work, much appreciated. Thanks everyone for your help.

  7. #7
    Registered User
    Join Date
    Nov 2012
    Posts
    1

    Re: Making a Log in Screen (VB6)

    Tnx @Yemit you've been a great help to my Log-in form it almost take me one night just to connect the form with the database.. )

  8. #8

  9. #9
    Fanatic Member gibra's Avatar
    Join Date
    Oct 2009
    Location
    ITALY
    Posts
    664

    Re: Making a Log in Screen (VB6)

    Quote Originally Posted by Edocsil View Post
    Thank you so much for your help mate, I have finally got this bugger of a thing to work, much appreciated. Thanks everyone for your help.
    A secure Log-in should be made using ADODB Command with Parameters to avoid SQL Injection
    http://en.wikipedia.org/wiki/SQL_injection

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.