Error: Invalid PInvoke metadata format
I am receiving Invalid PInvokde metadata format error while inserting a record into MS Access Database. Below is the complete code of my code behind file.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Page.IsPostBack Then
Try
Dim Mailer As New MailMessage
Mailer.From = "myemail@test.com"
Mailer.To = "toemail@test.com"
Mailer.Subject = "Testing Email in ASP.NET"
Mailer.BodyFormat = MailFormat.Text
Dim BodyText As String
BodyText = "The following information has been submitted:" & vbCrLf
BodyText = BodyText & "First Name:" & txtFirstName.Text & vbCrLf
BodyText = BodyText & "Last Name:" & txtLastName.Text & vbCrLf
BodyText = BodyText & "Email Address:" & txtEmail.Text & vbCrLf
Mailer.Body = BodyText
SmtpMail.SmtpServer = "mail-fwd"
SmtpMail.Send(Mailer)
Catch ex As Exception
End Try
'Inserting into the database
Dim strConnect As String
strConnect = "Provider=Microsoft.Jet.Oledb.4.0;Data Source=" & Server.MapPath("/data/mydb.mdb")
Dim objConn As New OleDbConnection(strConnect)
Dim strSQL As String
strSQL = "INSERT INTO myTable (FirstName,LastName,Email) VALUES ('" & txtFirstName.Text & "','" & txtLastName.Text & "','" & txtEmail.Text & "')"
Dim ObjCommand As New OleDbCommand
With ObjCommand
.CommandText = strSQL
.Connection = objConn
End With
Try
objConn.Open()
ObjCommand.ExecuteNonQuery()
lblMessage.Text = "One Record inserted."
Catch ex As Exception
lblMessage.Text = ex.Message
Finally
'closing the connection
objConn.Close()
End Try
End If
End Sub
|