Hi! So i am kinda of new to asp. I have created a registration page in vb.net. The information is suppose to be handed off into msaccess database, however it doesn't actually send the information. It will send the Email however to the user. The code is listed below. Can someone tell me why it does not send the code to the databse! Thanks and it is greatly appreciated
'code
Imports System.Web.Mail
Imports System.Data
Imports System.Data.OleDb
'end code
Partial Class _Default
Inherits System.Web.UI.Page
'set the variables needed
Dim SqlConnectionString As String
Dim SqlConnectionStatus As String = "Closed"
Dim Sqlconnection As New OleDbConnection
Dim Sqlcommand As New OleDbCommand(sqlinsert, Sqlconnection)
Dim SqlData As OleDbDataReader
Dim sqlinsert As String
'Function used to open the Database
Function sqlDBconnection() As Object
'creating the connection string
SqlConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=FDXDB3.mdb"
'set the connection string into the SQL connection
Sqlconnection.ConnectionString = SqlConnectionString
'open the connection
Sqlconnection.Open()
'Check to see if it was successful
If Sqlconnection.State = ConnectionState.Open Then
'Set the connection status to open
SqlConnectionStatus = "Open"
End If
'Return the connection status
Return SqlConnectionStatus
End Function
'Function used to close the database
Function SqlDBConnectionClose() As Object
'close the connection
Sqlconnection.Close()
'check to see if the connection is closed or open
If Sqlconnection.State = ConnectionState.Open Then
'Keep the connection as Open
SqlConnectionStatus = "Open"
Else
'Set the Connection Status as Closed
SqlConnectionStatus = "Closed"
End If
Return SqlConnectionStatus
End Function
Function InsertinDB() As Object
End Function
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
'This opens the Database so you can enter information into ti
Try
sqlDBconnection()
Catch ex As Exception
'If it doesnt, then it will display the error message
Response.Write(ex.Message)
End Try
sqlinsert = "INSERT into FDXUSER(First_Name,Last_Name,Email,Station_ID,User_Name,Password,SQ_1,SA_1,SQ_2,SA_2,SQ_3,SA_3,Security_Level)Values(" & first_name.Text & "," & last_name.Text & "," & email_address.Text & ",'" & Stationident.SelectedValue & "'," & User_Name.Text & "," & password1.Text & "," & "*,*,*,*,*,*,3)"
Try
Sqlcommand.CommandText = sqlinsert
Sqlcommand.Connection = Sqlconnection
Sqlcommand.ExecuteNonQuery()
Catch ex As Exception
Response.Write(ex.Message)
End Try
'This will close the DB
Try
SqlDBConnectionClose()
Catch ex As Exception
Response.Write(ex.Message)
End Try
'This will close the database
SqlDBConnectionClose()
'Below will send out an email to the following email that was provided
Try
Dim theMessage As String
password1.Text.ToUpper()
password2.Text.ToUpper()
theMessage = "Thank you for subscribing to the Fedex Newsletter<br/>"
theMessage += "This email contains your membership details. Please keep it safe<br/>"
theMessage += "If you lose this information, please contact administration to obtain this info<br/>"
theMessage += "Below is your login information:<br/>"
theMessage += "Username: " + User_Name.Text + "<br/>"
If password1.Text = password2.Text Then
theMessage += "Password: " + password1.Text + "<br/>"
Else
Dim ex As String = "Sorry Your first password is different from your second"
Response.Write(ex)
Return
End If
theMessage += "Thanks for using our website"
Dim mailMessage As New MailMessage()
mailMessage.From = "tyleryokley@hotmail.com"
mailMessage.To = email_address.Text
mailMessage.Subject = "Account Information"
mailMessage.BodyFormat = MailFormat.Html
mailMessage.Body = theMessage
mailMessage.Priority = MailPriority.High
SmtpMail.SmtpServer = "smtp.comcast.net"
SmtpMail.Send(mailMessage)
Response.Redirect("confirmreg.htm")
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Sub
End Class