Click here to Skip to main content
15,891,905 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Error on - 4th line says that compile error " user defined type not defined.

VB
'CHECKING Username and password
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.MDB"
Cmd = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & db & ""

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 28-Oct-14 11:14am
v2
Comments
Richard Deeming 3-Nov-14 17:35pm    
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.

1 solution

You need to add reference to Microsoft ActiveX Data Objects Library x.x
Check this: Using ADO with Microsoft Visual Basic[^]
 
Share this answer
 
Comments
Lamichhane 28-Oct-14 21:56pm    
Thank you so much. but again another error came says that file couldn't find(db = App.Path & "\nfl.mdb"). where i clearly put file name as nfl.
Maciej Los 29-Oct-14 2:24am    
Check what App.Path returns ;)
Did my answer helped you to solve your primary issue? If yes, please, mark may answer as a solution. If you have another question, please post it on QA via using "Ask a question" widget.

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