Hi,
If I run the following:
strSQL = "Select * FROM Clients;"
da = New OleDb.OleDbData Adapter(strSQL, Conn) 'Create data adapter
cb = New OleDb.OleDbComm andBuilder(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("Client ID")) 'Set the currentClientID to this new client
rw("RelatedClie ntLinkID") = CurrentRelatedC lientID 'Type is: Long.
rw("IsPrimaryCl ient") = True
rw("Title") = txtTitleSelf.Te xt 'Type is: String.
rw("Forename") = txtForenameSelf .Text 'Type is: String.
rw("OtherNames" ) = txtOtherNameSel f.Text 'Type is: String.
rw("Surname") = txtSurnameSelf. Text 'Type is: String.
rw("Relationshi pToPartner") = txtRelToPartner Self.Text 'Type is: String.
rw("DOB") = txtDOBYYYYSelf. Text & "-" & txtDOBMMSelf.Te xt & "-" & txtDOBDDSelf.Te xt 'Type is: Date.
rw("StateOfHeal th") = txtStateOfHealt hSelf.Text 'Type is: String.
rw("SmokerYN") = chkSmokerSelf.C hecked 'Type is: Boolean.
rw("Notes") = txtNotesSelf.Te xt '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.OleDbData Adapter(strSQL, Conn) 'Create data adapter
cb = New OleDb.OleDbComm andBuilder(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("Client ID")) 'Set the currentClientID to this new client
rw("RelatedClie ntLinkID") = CurrentRelatedC lientID 'Type is: Long.
rw("IsPrimaryCl ient") = True
rw("Title") = txtTitleSelf.Te xt 'Type is: String.
rw("Forename") = txtForenameSelf .Text 'Type is: String.
rw("OtherNames" ) = txtOtherNameSel f.Text 'Type is: String.
rw("Surname") = txtSurnameSelf. Text 'Type is: String.
rw("Relationshi pToPartner") = txtRelToPartner Self.Text 'Type is: String.
rw("DOB") = txtDOBYYYYSelf. Text & "-" & txtDOBMMSelf.Te xt & "-" & txtDOBDDSelf.Te xt 'Type is: Date.
rw("StateOfHeal th") = txtStateOfHealt hSelf.Text 'Type is: String.
rw("SmokerYN") = chkSmokerSelf.C hecked 'Type is: Boolean.
rw("Notes") = txtNotesSelf.Te xt '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.
Comment