H
Heather
I've read through all the posts regarding autonumber and am still
struggling. I have a SQL200 database, all inserts and updates are
done via stored procedures. My inserts, determine the next id, create
the new record with the new ID and pass the id back in an output
parameter. I am sucessfully getting the new value back but have an
issues with the Merge. Here is a subset of my code:
dsChanges = dsMeds.GetChanges
If Not dsChanges Is Nothing Then
Try
cnnMeds.Open()
daMeds.Update(dsChanges, dsChanges.Tables(0).TableName)
dsMeds.Merge(dsChanges)
dsMeds.AcceptChanges()
Return True
Catch updateException As System.Exception
MsgBox("Error Updating Medications:" & vbCrLf &
updateException.ToString, , "SaveChanges")
Finally
cnnMeds.Close()
End Try
End If
The problem is, after an Insert, I end up with 2 rows in my grid for
the one record inserted. I know this is due to the merge combining
based on ID, and the original dataset has a ID value of a negative
number and the changes dataset has the new ID, so it results in two
rows.
Is there a way to fix this other than just refilling the original
dataset from the database?
Thanks!
struggling. I have a SQL200 database, all inserts and updates are
done via stored procedures. My inserts, determine the next id, create
the new record with the new ID and pass the id back in an output
parameter. I am sucessfully getting the new value back but have an
issues with the Merge. Here is a subset of my code:
dsChanges = dsMeds.GetChanges
If Not dsChanges Is Nothing Then
Try
cnnMeds.Open()
daMeds.Update(dsChanges, dsChanges.Tables(0).TableName)
dsMeds.Merge(dsChanges)
dsMeds.AcceptChanges()
Return True
Catch updateException As System.Exception
MsgBox("Error Updating Medications:" & vbCrLf &
updateException.ToString, , "SaveChanges")
Finally
cnnMeds.Close()
End Try
End If
The problem is, after an Insert, I end up with 2 rows in my grid for
the one record inserted. I know this is due to the merge combining
based on ID, and the original dataset has a ID value of a negative
number and the changes dataset has the new ID, so it results in two
rows.
Is there a way to fix this other than just refilling the original
dataset from the database?
Thanks!