 |
Experts on Demand
I'm using Pervasive SQL with VB.NET. I create a data table via primary keys, NameKey and DateKey. I want to then make a copy of that table, change the DateKey for all records in that table, and put it back in the database. Is there an easier or faster way than going row by row? Below is my code:
'Create table to copy from
FromDT = New DataTable(TableName)
FromRS = "select * from " & TableName & " WHERE NameKey = '" & FromKey & "' AND DateKey = '" & FromDate & "'; "
FromDA = New OleDbDataAdapter(FromRS, CN) FromCB = New OleDbCommandBuilder(FromDA) FromDA.FillSchema(FromDT, SchemaType.Mapped)
FromDA.Fill(FromDT)
'Create table to copy to
ToDT = New DataTable(TableName)
ToRS = "select * from " & TableName & " WHERE NameKey = '" & TOKey & "' AND DateKey = '" & TODate & "'; "
ToDA = New OleDbDataAdapter(ToRS, CN)
ToCB = New OleDbCommandBuilder(ToDA)
ToDA.FillSchema(ToDT, SchemaType.Mapped)
ToDA.Fill(ToDT)
Dim Toclonerow As DataRow
For i = 0 To FromDT.Rows.Count - 1
Toclonerow = FromDT.Rows.Item(i)
Toclonerow.Item("DateKey") = TODate
ToDT.Rows.Add(Toclonerow.ItemArray)
Next
ToDA.Update(ToDT)
ToDT.AcceptChanges()
QUESTION POSED ON: 15 APR 2005
QUESTION ANSWERED BY: Samuel Matzen
There may be some minor refinements, but from what I know there is no easy way to do this.
|
 |
|
|
 |
 |
 |
 |
| TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of . |
|
| |
All Rights Reserved, , TechTarget |
|
|
|
|
|