E
Earl
My Update logic worked .. and now it doesn't. I went back, examined the
stored procedure carefully, examined the table structure carefully, and
examined the parameters collection carefully. All names, datatypes, and
sizes match up. In this particular table, all values can be set to Null
except for the primary key, SalesID. So as part of my testing to ensure the
data itself wasn't the cause of the error, I tried Updating all DBNull
values to every column except for the primary key ... still no success.
The dataset is global, and the datatable is dimmed Private to the form
class.
The datatable shows a count of 1 row right before I try to update.
The dataset returns True on HasChanges right before I try to submit the
update.
All parameters in the Update function match perfectly with the stored
procedure.
I've used similar logic in more than a dozen forms in the same app, but I'm
stumped -- everything looks correct, but I still get a "Concurrency error,
no records have been updated" when it hits the da.Update(dsChanges,
"dtSales") command. Anyone see anything?
Try-catch removed for readability.
**********************************************
Dim strSQLServer As New SqlConnection(strConnString)
strSQLServer.Open()
dtSales = ds.Tables("dtSales")
Dim m_intSalesID As Int32 = CInt(dtSales.Rows(0)("SalesID"))
dtSales.Rows(0)("SalesID") = m_intSalesID
.....
'(all remaining fields set to DbNull)
Dim dsChanges As DataSet
dsChanges = ds.GetChanges
Dim da As New SqlDataAdapter
' CreateSaleUpdate() is a function that returns a command with all
parameters
da.UpdateCommand = CreateSaleUpdate()
da.Update(dsChanges, "dtSales")
ds.AcceptChanges()
strSQLServer.Close()
stored procedure carefully, examined the table structure carefully, and
examined the parameters collection carefully. All names, datatypes, and
sizes match up. In this particular table, all values can be set to Null
except for the primary key, SalesID. So as part of my testing to ensure the
data itself wasn't the cause of the error, I tried Updating all DBNull
values to every column except for the primary key ... still no success.
The dataset is global, and the datatable is dimmed Private to the form
class.
The datatable shows a count of 1 row right before I try to update.
The dataset returns True on HasChanges right before I try to submit the
update.
All parameters in the Update function match perfectly with the stored
procedure.
I've used similar logic in more than a dozen forms in the same app, but I'm
stumped -- everything looks correct, but I still get a "Concurrency error,
no records have been updated" when it hits the da.Update(dsChanges,
"dtSales") command. Anyone see anything?
Try-catch removed for readability.
**********************************************
Dim strSQLServer As New SqlConnection(strConnString)
strSQLServer.Open()
dtSales = ds.Tables("dtSales")
Dim m_intSalesID As Int32 = CInt(dtSales.Rows(0)("SalesID"))
dtSales.Rows(0)("SalesID") = m_intSalesID
.....
'(all remaining fields set to DbNull)
Dim dsChanges As DataSet
dsChanges = ds.GetChanges
Dim da As New SqlDataAdapter
' CreateSaleUpdate() is a function that returns a command with all
parameters
da.UpdateCommand = CreateSaleUpdate()
da.Update(dsChanges, "dtSales")
ds.AcceptChanges()
strSQLServer.Close()