Is the error I am getting when updating. Where a, I going wrong, this is
driving me nuts
Sub add_Person(Optional ByVal frmNewPerson As frmPerson = Nothing)
'Debug.WriteLine("add_Person")
Dim DR As DataRow
Dim InsertCmd As New OleDbCommand
'Open the connection
con.Open()
'Set up the insert command
InsertCmd.CommandType = CommandType.Text
InsertCmd.CommandText = "INSERT INTO [People]([Address1], [Address2],
[Address3], [Address4], [Country], [County], [DOB], " & _
", [FirstName], [Home Phone], [LastName], [MiddleInnitial], [Mobile
Fone], [Post Code]," & _
"[Town]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
InsertCmd.Connection = con
InsertCmd.Parameters.Add(New System.Data.OleDb.OleDbParameter("Address1",
System.Data.OleDb.OleDbType.VarWChar, 50, "Address1"))
InsertCmd.Parameters.Add(New System.Data.OleDb.OleDbParameter("Address2",
System.Data.OleDb.OleDbType.VarWChar, 50, "Address2"))
InsertCmd.Parameters.Add(New System.Data.OleDb.OleDbParameter("Address3",
System.Data.OleDb.OleDbType.VarWChar, 50, "Address3"))
InsertCmd.Parameters.Add(New System.Data.OleDb.OleDbParameter("Address4",
System.Data.OleDb.OleDbType.VarWChar, 50, "Address4"))
InsertCmd.Parameters.Add(New System.Data.OleDb.OleDbParameter("Country",
System.Data.OleDb.OleDbType.VarWChar, 50, "Country"))
InsertCmd.Parameters.Add(New System.Data.OleDb.OleDbParameter("County",
System.Data.OleDb.OleDbType.VarWChar, 50, "County"))
InsertCmd.Parameters.Add(New System.Data.OleDb.OleDbParameter("DOB",
System.Data.OleDb.OleDbType.DBDate, 0, "DOB"))
InsertCmd.Parameters.Add(New System.Data.OleDb.OleDbParameter("Email",
System.Data.OleDb.OleDbType.VarWChar, 50, "Email"))
InsertCmd.Parameters.Add(New System.Data.OleDb.OleDbParameter("FirstName",
System.Data.OleDb.OleDbType.VarWChar, 20, "FirstName"))
InsertCmd.Parameters.Add(New System.Data.OleDb.OleDbParameter("Home_Phone",
System.Data.OleDb.OleDbType.VarWChar, 50, "Home Phone"))
InsertCmd.Parameters.Add(New System.Data.OleDb.OleDbParameter("LastName",
System.Data.OleDb.OleDbType.VarWChar, 20, "LastName"))
InsertCmd.Parameters.Add(New
System.Data.OleDb.OleDbParameter("MiddleInnitial",
System.Data.OleDb.OleDbType.VarWChar, 3, "MiddleInnitial"))
InsertCmd.Parameters.Add(New System.Data.OleDb.OleDbParameter("Mobile_Fone",
System.Data.OleDb.OleDbType.VarWChar, 50, "Mobile Fone"))
InsertCmd.Parameters.Add(New System.Data.OleDb.OleDbParameter("Post_Code",
System.Data.OleDb.OleDbType.VarWChar, 10, "Post Code"))
InsertCmd.Parameters.Add(New System.Data.OleDb.OleDbParameter("Town",
System.Data.OleDb.OleDbType.VarWChar, 50, "Town"))
'
daPeople.InsertCommand = InsertCmd
'Genereate New Row
DR = tablePeople.NewRow()
DR("FirstName") = frmNewPerson.txtFirstName.Text
DR("LastName") = frmNewPerson.txtLastName.Text
DR("DOB") = frmNewPerson.txtDOB.Text
DR("Home Phone") = frmNewPerson.txtHomeFone.Text
DR("Mobile Fone") = frmNewPerson.txtMobileFone.Text
DR("Email") = frmNewPerson.txtEmail.Text
DR("Address1") = frmNewPerson.txtAddress1.Text
DR("Address2") = frmNewPerson.txtAddress2.Text
DR("Address3") = frmNewPerson.txtAddress3.Text
DR("Address4") = frmNewPerson.txtAddress4.Text
DR("Town") = frmNewPerson.txtTown.Text
DR("County") = frmNewPerson.txtCounty.Text
DR("Post Code") = frmNewPerson.txtPostCode.Text
DR("Country") = frmNewPerson.txtCountry.Text
DR("MiddleInnitial") = ""
tablePeople.Rows.Add(DR)
Try
daEvents.Update(tablePeople)
Catch ex As OleDbException
MessageBox.Show(ex.Message())
End Try
tablePeople.Clear()
daPeople.Fill(tableEvents)
tablePeople.AcceptChanges()
'Close the connection
con.Close()
--
Regards - One Handed Man
Author : Fish .NET & Keep .NET
==============================