PC Review


Reply
Thread Tools Rate Thread

datarow duplication and unique key conflicts

 
 
claudio.benghi@gmail.com
Guest
Posts: n/a
 
      28th Dec 2005
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

 
Reply With Quote
 
 
 
 
claudio.benghi@gmail.com
Guest
Posts: n/a
 
      28th Dec 2005
Hey... pushed "Post" before cheering...

:-)

thanks for any Suggestion...
Claudio Benghi

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is DataRow[string] uses DataRow[int] and DataRow[int] much efficient than DataRow[string]? Ryan Liu Microsoft C# .NET 3 2nd Feb 2008 06:14 AM
Distinguish 2 situations when a DataRow in Detached state; Or why not make the data row intact after being added then removed from a dataRow collection? Ryan Liu Microsoft Dot NET 0 7th Jun 2006 03:04 PM
Distinguish 2 situations when a DataRow in Detached state; Or why not make the data row intact after being added then removed from a dataRow collection? Ryan Liu Microsoft C# .NET 0 7th Jun 2006 02:14 AM
create new DataRow, init fields, then set DataRow to UnChanged? Les Caudle Microsoft ADO .NET 2 4th May 2004 05:42 PM
Re: Casting Data.Datarow to a strongly typed datarow CJ Taylor Microsoft VB .NET 4 21st Apr 2004 08:09 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:53 AM.