-----------------------------------------------------------
New Message on MumbaiUserGroup
-----------------------------------------------------------
From: BabuRaj109791
Message 4 in Discussion
New Message on MumbaiUserGroup
How to copy an existing row into the same datatable ?
Reply
Reply to Sender
Recommend
Message 3 in Discussion
From:
BabuRaj109791
Hi, I tried this method but I'm still getting the same error.Is
there any other alternative way ? My code is as below.
'''Get the row position of the row to copy
'''***************************************
Dim olddr As DataRow
rowpos = CInt(e.Item.ItemIndex + 1)
MyCommand = New SqlDataAdapter("select * from testbabu", myConnection)
DS = New DataSet
MyCommand.Fill(DS, "table1")
dt = DS.Tables(0)
dr = DS.Tables(0).NewRow()
'Get the entire row to be copied
'*******************************
For Each dr In dt.Rows
If cnt = CInt(e.Item.ItemIndex) Then
olddr = dt.Rows(cnt)
Exit For
End If
cnt = cnt + 1
Next
intCols = DS.Tables(0).Columns.Count - 1
For i = 0 To intCols
dr(i) = olddr(i)
Next
'Insert the row at a particular position
'***************************************
DS.Tables(0).Rows.InsertAt(dr, rowpos)
MyCommand.Update(DS, "table1")
DS.Tables(0).AcceptChanges()
DataGrid1.DataSource = DS.Tables("table1").DefaultView
DataGrid1.DataBind()
View other groups in this category.
-----------------------------------------------------------
To stop getting this e-mail, or change how often it arrives, go to your E-mail
Settings.
http://groups.msn.com/mumbaiusergroup/_emailsettings.msnw
Need help? If you've forgotten your password, please go to Passport Member
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help
For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact
If you do not want to receive future e-mail from this MSN group, or if you
received this message by mistake, please click the "Remove" link below. On the
pre-addressed e-mail message that opens, simply click "Send". Your e-mail
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]