F
Frank Bacon
I run this code without error. I create a recordset of the changes, the row
I want to add, but the Update command doesn't add the records to the DB.
The Update Command returns a zero indicating that no records change. I'm
lost does anyone have any ideas?
'Open Appropriate VAR Table
strSql = "Select * FROM [" + CStr(dcSheetName.ColumnName) + "]
ORDER BY [Date];"
dsVarTables = CreateDataSet(strSql, myConnection)
daVarTables = New OleDbDataAdapter()
daVarTables.SelectCommand = New OleDbCommand(strSql,
myConnection)
NewRow = dsVarTables.Tables(dcSheetName.ColumnName).NewRow()
oleCB = New OleDbCommandBuilder(daVarTables)
oleDBC = oleCB.GetInsertCommand
strSql = oleDBC.CommandText "Used this to make sure I had a
valid INSERT statement
The code Fills each Value in new Data Row....
..
..
..
dsVarTables.Tables(dcSheetName.ColumnName).Rows.Add(NewRow)
dsChanges = dsVarTables.GetChanges(DataRowState.Added)
dbgChanges.DataSource = dsChanges.Tables(1)
dbgChanges.Refresh()
If NewRow.HasErrors() = True Then MsgBox("New Row Has Errors")
Try
RecUpdated = daVarTables.Update(dsChanges)
Catch err As Exception
MessageBox.Show(err.Message)
End Try
MsgBox((dcSheetName.ColumnName) + Str(RecUpdated) + " records
Updated", MsgBoxStyle.OKOnly)
I want to add, but the Update command doesn't add the records to the DB.
The Update Command returns a zero indicating that no records change. I'm
lost does anyone have any ideas?
'Open Appropriate VAR Table
strSql = "Select * FROM [" + CStr(dcSheetName.ColumnName) + "]
ORDER BY [Date];"
dsVarTables = CreateDataSet(strSql, myConnection)
daVarTables = New OleDbDataAdapter()
daVarTables.SelectCommand = New OleDbCommand(strSql,
myConnection)
NewRow = dsVarTables.Tables(dcSheetName.ColumnName).NewRow()
oleCB = New OleDbCommandBuilder(daVarTables)
oleDBC = oleCB.GetInsertCommand
strSql = oleDBC.CommandText "Used this to make sure I had a
valid INSERT statement
The code Fills each Value in new Data Row....
..
..
..
dsVarTables.Tables(dcSheetName.ColumnName).Rows.Add(NewRow)
dsChanges = dsVarTables.GetChanges(DataRowState.Added)
dbgChanges.DataSource = dsChanges.Tables(1)
dbgChanges.Refresh()
If NewRow.HasErrors() = True Then MsgBox("New Row Has Errors")
Try
RecUpdated = daVarTables.Update(dsChanges)
Catch err As Exception
MessageBox.Show(err.Message)
End Try
MsgBox((dcSheetName.ColumnName) + Str(RecUpdated) + " records
Updated", MsgBoxStyle.OKOnly)