C
copyco
I've seen example after example on this and I'm just not getting it. I
just can't seem to get changes from my datagrid to write back to the
table that it's from. I'm trying to use a commandbuilder object to
write the changes in the datagrid back to the table. I'm getting an
error on the "dataAdapter.Update" method. The error states that there's
a syntax error in the "INSERT INTO statement." When I view the debug
output of the commandText, it has question marks in the SQL statement
where the parameters go. Should those be automatically replaced, or are
those what is causing the syntax error? I'm really lost and need help.
There is something I'm missing. Any help is appreciated. My code
is below.
'add new Number to the Datagrid...
dvNumbers.AllowNew = True
Dim newRow As DataRowView = dvNumbers.AddNew
newRow("number") = comNum
newRow("comName") = comName
newRow("callCount") = 1
newRow("lastCall") = vNow
newRow("blocked") = vBlocked
newRow.EndEdit()
dvNumbers.AllowNew = False
'add new Number to the Table...
Dim cbNumbers As New OleDbCommandBuilder(daNumbers)
daNumbers.InsertCommand = cbNumbers.GetInsertCommand
Debug.WriteLine(daNumbers.InsertCommand.CommandText)
daNumbers.Update(dsNumbers, "Numbers") '** ERROR line
just can't seem to get changes from my datagrid to write back to the
table that it's from. I'm trying to use a commandbuilder object to
write the changes in the datagrid back to the table. I'm getting an
error on the "dataAdapter.Update" method. The error states that there's
a syntax error in the "INSERT INTO statement." When I view the debug
output of the commandText, it has question marks in the SQL statement
where the parameters go. Should those be automatically replaced, or are
those what is causing the syntax error? I'm really lost and need help.
There is something I'm missing. Any help is appreciated. My code
is below.
'add new Number to the Datagrid...
dvNumbers.AllowNew = True
Dim newRow As DataRowView = dvNumbers.AddNew
newRow("number") = comNum
newRow("comName") = comName
newRow("callCount") = 1
newRow("lastCall") = vNow
newRow("blocked") = vBlocked
newRow.EndEdit()
dvNumbers.AllowNew = False
'add new Number to the Table...
Dim cbNumbers As New OleDbCommandBuilder(daNumbers)
daNumbers.InsertCommand = cbNumbers.GetInsertCommand
Debug.WriteLine(daNumbers.InsertCommand.CommandText)
daNumbers.Update(dsNumbers, "Numbers") '** ERROR line