Hi,Im trying to do an insert to the database with a dataset that has been merged with another dataset containing the new record i want to write. The merge works no problem but the database isnt updated. the code works for tables without any primary keys but causes a constraint violation for a table with a primary key.
Here is the code for the insert function:
Public Function dsinserter(ByRef ds As DataSet, ByVal strsql As String, ByVal xds As DataSet) As Boolean
Dim objconn As New OdbcConnection(getconstring)
Dim objadapter As New OdbcDataAdapter(strsql, objconn)
Dim cb As New OdbcCommandBuilder(objadapter)
Try
objadapter.AcceptChangesDuringFill = False
objadapter.Fill(xds, "details")
xds.Merge(ds.Tables("details"), false, MissingschemaAction.Ignore)
objadapter.Update(xds.Tables("details"))
Return True
Catch e As Exception
msLastError = e.Message
Return False
End Try
End Function
Ive done alot of searching for answers but without any luck. Any ideas on how i can get this to work with a table which has a primary key?
Thank you.
Here is the code for the insert function:
Public Function dsinserter(ByRef ds As DataSet, ByVal strsql As String, ByVal xds As DataSet) As Boolean
Dim objconn As New OdbcConnection(getconstring)
Dim objadapter As New OdbcDataAdapter(strsql, objconn)
Dim cb As New OdbcCommandBuilder(objadapter)
Try
objadapter.AcceptChangesDuringFill = False
objadapter.Fill(xds, "details")
xds.Merge(ds.Tables("details"), false, MissingschemaAction.Ignore)
objadapter.Update(xds.Tables("details"))
Return True
Catch e As Exception
msLastError = e.Message
Return False
End Try
End Function
Ive done alot of searching for answers but without any luck. Any ideas on how i can get this to work with a table which has a primary key?
Thank you.