Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

You can not get ye flask.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...