Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
please help me . i have tried all above idea in this below code but i am not able to connect to vb6 with access. please help me out and provide me correct code which connect to the vb6 with access. please help me.

CHECKING Username and password
VB
Public Function validuser(Username As String, password As String)
 
Dim db As String
Dim Cmd As String
Dim sql As String
Dim Cn As ADODB.Connection
Dim rs As ADODB.Recordset
 
db = App.Path & "\nfl.accdb"
'Data Source = "C:\Users\Sanat\Desktop\Class project\nfl.accdb"
'Cmd = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & db & ""
Provider = "Microsoft.ACE.OLEDB.12.0; Data Souurce= C:\Users\Sanat\Desktop\Class project\nfl.accdb;"
'OLEDB: Database password = myDbpassword
Persist security Info= False;
Set Cn = New ADODB.Connection
 
With Cn
.ConnectionString = Cmd
.Open
End With
 

 
Set rs = New ADODB.Recordset
 

sql = "Select * From [Security] where Username LIKE '" & Username & "' and Password LIKE '" & password & "'"
rs.Open sql, Cn, adOpenForwardOnly, adLockReadOnly
 

If Not rs.EOF Then
validuser = True
Else
validuser = False
End If

rs.Close
Set rs = Nothing
 
Cn.Close
Set Cn = Nothing
End Function
Posted
Updated 2-Nov-14 16:04pm
v2
Comments
DamithSL 2-Nov-14 21:53pm    
what is the error you get?
Richard Deeming 3-Nov-14 17:33pm    
Your code is vulnerable to SQL Injection[^].

NEVER use string concatenation to build a SQL query. ALWAYS use a parameterized query.

Also, you're storing passwords in plain text. That is a very bad idea. You should only ever store a salted hash of the user's password, using multiple rounds of a strong hashing algorithm.
Lamichhane 3-Nov-14 23:34pm    
Can you give me some example how to connect VB to access ? i hope you understand my project. i am trying to create various form where log in form is one of those. in the log in form, there are security check, if password and user name match then only it move to another form.

The main problem is i am not able to connect with access, where i have stored username and password. now please provide me some coding which i can connect with the access.

1 solution

Check this

database-access-vb6-data-control-tutorial[^]

Hope it will help.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900