-
Apr 24th, 2009, 01:31 AM
#1
Thread Starter
New Member
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
-
Apr 24th, 2009, 02:52 AM
#2
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.
-
Apr 24th, 2009, 02:52 AM
#3
Addicted Member
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
-
Apr 24th, 2009, 03:10 AM
#4
Thread Starter
New Member
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
-
Apr 24th, 2009, 08:30 AM
#5
Junior Member
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
-
Apr 25th, 2009, 08:58 PM
#6
Thread Starter
New Member
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.
-
Nov 26th, 2012, 08:09 PM
#7
Registered User
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.. )
-
Nov 27th, 2012, 04:40 PM
#8
Re: Making a Log in Screen (VB6)
Last edited by gibra; Nov 27th, 2012 at 04:44 PM.
-
Nov 27th, 2012, 04:43 PM
#9
Re: Making a Log in Screen (VB6)
Originally Posted by Edocsil
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|