Start a new topic

Copy Record From One Table to Another

Is there a way to copy a record from one table to another. Both tables have same structure?

If using SQL, you could use INSERT INTO:


INSERT INTO [destination]
SELECT * FROM [source]
WHERE [RowId] = RowId


If using DDA, you could use something like the following:



using (IVistaDBTableSchema schema = db.TableSchema(sourceTableName))
  using (IVistaDBTable sourceTbl = db.OpenTable(sourceTableName, true, true))
    using (IVistaDBTable destinationTbl = db.OpenTable(destinationTableName, true, false))
      // apply filter
      sourceTbl.SetFilter(filterExpression, optimizeFilter);

      // move to first record

      while (!sourceTbl.EndOfTable)
        // create new record

        // copy data
        for (int i = 0; i < schema.ColumnCount; i++)
          destinationTbl.Put(i, sourceTbl.Get(i));

        // save changes

        // advance source to next record



Thanks. I was looking for DDA.

Login to post a comment