datarow duplication and unique key conflicts

  • Thread starter Thread starter claudio.benghi
  • Start date Start date
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
 
Hey... pushed "Post" before cheering...

:-)

thanks for any Suggestion...
Claudio Benghi
 
Back
Top