Tried This
and I also tried this
and I also tried this
I do not have control to change the field "Contact Name". When I run the code I get
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in System.Data.dll
{"Syntax error in INSERT INTO statement."}
VB.NET:
Dim drNewRow As DataRow = m_dtContacts.NewRow()
With frmMain
drNewRow("ID") = .txtID.Text
drNewRow("Contact Name") = .txtContactName.Text
drNewRow("Address") = .txtAddress.Text
drNewRow("Town") = .txtTown.Text
drNewRow("County") = .txtCounty.Text
drNewRow("PostCode") = .txtPostCode.Text
drNewRow("PhoneNo") = .txtPhoneNo.Text
drNewRow("MobileNo") = .txtMobileNo.Text
drNewRow("Fax") = .txtFax.Text
drNewRow("email") = .txtemail.Text
End With
m_dtContacts.Rows.Add(drNewRow)
m_daContacts.Update(m_dtContacts)
m_intRowPosition = m_dtContacts.Rows.Count - 1
VB.NET:
Dim drNewRow As DataRow = m_dtContacts.NewRow()
With frmMain
drNewRow("ID") = .txtID.Text
drNewRow([Contact Name]") = .txtContactName.Text
drNewRow("Address") = .txtAddress.Text
drNewRow("Town") = .txtTown.Text
drNewRow("County") = .txtCounty.Text
drNewRow("PostCode") = .txtPostCode.Text
drNewRow("PhoneNo") = .txtPhoneNo.Text
drNewRow("MobileNo") = .txtMobileNo.Text
drNewRow("Fax") = .txtFax.Text
drNewRow("email") = .txtemail.Text
End With
m_dtContacts.Rows.Add(drNewRow)
m_daContacts.Update(m_dtContacts)
m_intRowPosition = m_dtContacts.Rows.Count - 1
VB.NET:
Dim drNewRow As DataRow = m_dtContacts.NewRow()
With frmMain
drNewRow(0) = CLng(.txtID.Text)
drNewRow(1) = .txtContactName.Text
drNewRow(2) = .txtAddress.Text
drNewRow(3) = .txtTown.Text
drNewRow(4) = .txtCounty.Text
drNewRow(5) = .txtPostCode.Text
drNewRow(6) = .txtPhoneNo.Text
drNewRow(7) = .txtMobileNo.Text
drNewRow(8) = .txtFax.Text
drNewRow(9) = .txtemail.Text
End With
m_dtContacts.Rows.Add(drNewRow)
m_daContacts.Update(m_dtContacts)
m_intRowPosition = m_dtContacts.Rows.Count - 1
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in System.Data.dll
{"Syntax error in INSERT INTO statement."}