Hello
Can I ask, please, that someone passes their eye over this to see that I have got it right and that it does what it is supposed to do which is: a) connect to the database; b) open it; c) check that the email address entered by the user is the same as in the Access email column called strEmail; and d) closes Access.
I have spent hours trying to resolve a 'connection doesn't initialize' with cmd.ExecuteNonQuery(), but I am now not getting that error.
Thanks for your time!
Can I ask, please, that someone passes their eye over this to see that I have got it right and that it does what it is supposed to do which is: a) connect to the database; b) open it; c) check that the email address entered by the user is the same as in the Access email column called strEmail; and d) closes Access.
I have spent hours trying to resolve a 'connection doesn't initialize' with cmd.ExecuteNonQuery(), but I am now not getting that error.
Code:
Protected Sub btnPassSend_Click(sender As Object, e As EventArgs) Handles btnPassSend.Click
Dim conn As New OleDbConnection
Dim OleDbConnection As New OleDbConnection
Dim cmd As New OleDbCommand
' Check if email field is empty
If UserEmail.Text = "" Then
ErrorMsg.Text = "Please complete the required fields"
ErrorMsg.Visible = True
End If
'Connect to Access
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|students.mdb;"
conn.Open()
cmd = New OleDbCommand("SELECT strEmail FROM university WHERE strEmail=@strEmail", conn)
'Check the user's email address in the strEmail column in Access corresponds to that entered by the user in
'the TextBox whose ID is "UserEmail"
cmd.Parameters.AddWithValue("@strEmail", UserEmail.Text)
cmd.Connection = conn
cmd.ExecuteNonQuery()
'close Access connection
conn.Close()
'SMTP code follows...
Thanks for your time!