datarow duplication and unique key conflicts

C

claudio.benghi

Hi all,

I need a quick way to create a new datarow based on an existing one
change a few values and update them to the database (the duplication
should be made in the same db table).

I've seen previous posts suggesting to use the ImportRow method for the
datatable...

i've tried it..

i see rows growing in the "in-memory" datatable... but updating to
database won't work...

any suggestion?

the code i'm using is:

Dim sql As String
sql = "select * from mytable"
Dim dt As New DataTable
Dim da As New OleDbDataAdapter
Dim cm As New OleDbCommand(sql, Conn)
da.SelectCommand = cm

Dim custCB As OleDbCommandBuilder = New OleDbCommandBuilder(da)
da.Fill(dt)
dt.ImportRow(dt.Rows(0))
dt.Rows(3)("myid") = 12

da.Update(dt)

"myid" is a numeric primary key
 
C

claudio.benghi

Hey... pushed "Post" before cheering...

:)

thanks for any Suggestion...
Claudio Benghi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top