S
Siv
Hi,
If I run the following:
strSQL = "Select * FROM Clients;"
da = New OleDb.OleDbDataAdapter(strSQL, Conn) 'Create data adapter
cb = New OleDb.OleDbCommandBuilder(da) 'Create command builder using the datadapter
dt = New Data.DataTable
da.Fill(dt) 'pour in the data using the adapter
rw = dt.NewRow
rw("ClientID") = GetNextIDNumber("Clients")
CurrentClientID = CLng(rw("ClientID")) 'Set the currentClientID to this new client
rw("RelatedClientLinkID") = CurrentRelatedClientID 'Type is: Long.
rw("IsPrimaryClient") = True
rw("Title") = txtTitleSelf.Text 'Type is: String.
rw("Forename") = txtForenameSelf.Text 'Type is: String.
rw("OtherNames") = txtOtherNameSelf.Text 'Type is: String.
rw("Surname") = txtSurnameSelf.Text 'Type is: String.
rw("RelationshipToPartner") = txtRelToPartnerSelf.Text 'Type is: String.
rw("DOB") = txtDOBYYYYSelf.Text & "-" & txtDOBMMSelf.Text & "-" & txtDOBDDSelf.Text 'Type is: Date.
rw("StateOfHealth") = txtStateOfHealthSelf.Text 'Type is: String.
rw("SmokerYN") = chkSmokerSelf.Checked 'Type is: Boolean.
rw("Notes") = txtNotesSelf.Text 'Type is: String.
rw("DateCreated") = Now 'Type is: Date.
rw("User") = CurrentUser 'Type is String
dt.Rows.Add(rw) 'Add the new row
da.Update(dt) 'Send the update to the actual database using the adapter
At the da.Update(dt) line I det an exception thrown: "Syntax error in INSERT INTO statement."
I have other code that uses the same technique and I don't get an error at all. I have tried changing the strSQL text so that it is more complex and it makes no difference.
If anyone can see the glaring mistake that I am making please put me out of my misery!
Siv
Martley, Worcester, UK.
If I run the following:
strSQL = "Select * FROM Clients;"
da = New OleDb.OleDbDataAdapter(strSQL, Conn) 'Create data adapter
cb = New OleDb.OleDbCommandBuilder(da) 'Create command builder using the datadapter
dt = New Data.DataTable
da.Fill(dt) 'pour in the data using the adapter
rw = dt.NewRow
rw("ClientID") = GetNextIDNumber("Clients")
CurrentClientID = CLng(rw("ClientID")) 'Set the currentClientID to this new client
rw("RelatedClientLinkID") = CurrentRelatedClientID 'Type is: Long.
rw("IsPrimaryClient") = True
rw("Title") = txtTitleSelf.Text 'Type is: String.
rw("Forename") = txtForenameSelf.Text 'Type is: String.
rw("OtherNames") = txtOtherNameSelf.Text 'Type is: String.
rw("Surname") = txtSurnameSelf.Text 'Type is: String.
rw("RelationshipToPartner") = txtRelToPartnerSelf.Text 'Type is: String.
rw("DOB") = txtDOBYYYYSelf.Text & "-" & txtDOBMMSelf.Text & "-" & txtDOBDDSelf.Text 'Type is: Date.
rw("StateOfHealth") = txtStateOfHealthSelf.Text 'Type is: String.
rw("SmokerYN") = chkSmokerSelf.Checked 'Type is: Boolean.
rw("Notes") = txtNotesSelf.Text 'Type is: String.
rw("DateCreated") = Now 'Type is: Date.
rw("User") = CurrentUser 'Type is String
dt.Rows.Add(rw) 'Add the new row
da.Update(dt) 'Send the update to the actual database using the adapter
At the da.Update(dt) line I det an exception thrown: "Syntax error in INSERT INTO statement."
I have other code that uses the same technique and I don't get an error at all. I have tried changing the strSQL text so that it is more complex and it makes no difference.
If anyone can see the glaring mistake that I am making please put me out of my misery!
Siv
Martley, Worcester, UK.