-
April 10th, 2012, 05:00 PM
#1
Help with a SELECT statement
Hello,
I'm trying to make a login system on visual basic. I need it to be able to connect to an access database to find the usernames and passwords. I have coded it as follows:
Code:
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
'Purpose: Make a Connection to the database and fill a Dataset with the Account and AccountTrans records
'Create a memory cell to store the drive letter of the USB drive
Dim DriveLetter As Char
'Get the first charatcer, i.e. the drive letter from the application's StartupPath
DriveLetter = Application.StartupPath.Substring(0, 1)
Dim con As New OleDbConnection("Provider=Microsoft.ACE.… Source=" & DriveLetter & ":\greenparkschool\AccessPoints.accdb")
Dim cmd As OleDbCommand = New OleDbCommand("SELECT * FROM Account WHERE cusername = '" & txtUsername.Text & "'" And cpassword = '" & txtCpassword.Text & "' ", con)
con.Open()
Dim sdr As OleDbDataReader = cmd.ExecuteReader()
'If the record can be queried, Pass verification and open another form.
If (sdr.Read() = True) Then
MessageBox.Show("The user is valid!")
Dim transaction As New transaction
transaction.Show()
Me.Hide()
Else
MessageBox.Show("Invalid username or password!")
End If
End Sub
The problem with this is that it says in the error log that an expression is expected and 'cmd' is not declared. The last section of the SELECT statement seems to comment itself out. What can I do to fix this?
Thanks in advance.
-
April 10th, 2012, 05:45 PM
#2
Re: Help with a SELECT statement
The first thing that comes to my mind is that you are in the wrong forum. Everything looks like it was VB.NET what you are using. So maybe you better post there?
-
April 10th, 2012, 05:47 PM
#3
Re: Help with a SELECT statement
Oh Ok, sorry about that, ill take it there.
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
|