[dba-VB] Copy tables

Gustav Brock Gustav at cactus.dk
Wed Feb 6 02:16:09 CST 2008


Hi Stuart

That is what I imagined initially.
Problem is, however and to my surprise, that neither a DataSet nor a DataTable features an Update method.

So what to do? 
I can't believe you have to revert to pure SQL commands to write back an update of a DataSet or DataTable??

/gustav


>>> stuart at lexacorp.com.pg 06-02-2008 00:11 >>>
I think you need to follow with kunderT.Update to update the underlying database from the 
TableAdapter.

On 5 Feb 2008 at 18:02, Gustav Brock wrote:

> Hi Stuart et al
> 
> No there is no GUI, just code.
> I have some code like this. It add rows but will not save them to the database table:
> 
>                 VrsSourceTableAdapters.DataTableKundeTableAdapter kundeAdapterS =
>                     new VrsSourceTableAdapters.DataTableKundeTableAdapter();
>                 VrsSource.DataTableKundeDataTable kunderS;
> 
>                 VrsTargetTableAdapters.DataTableKundeTableAdapter kundeAdapterT =
>                     new VrsTargetTableAdapters.DataTableKundeTableAdapter();
>                 VrsTarget.DataTableKundeDataTable kunderT;
> 
>                 kunderS = kundeAdapterS.GetDataVrsKunder();
>                 kunderT = kundeAdapterT.GetDataVrsKunder();
> 
>                 foreach (VrsSource.DataTableKundeRow kundeRowS in kunderS)
>                 {
>                     Console.WriteLine("Kunde: " + kundeRowS.navn + "");
>                     Console.WriteLine("  Kundenr: " + kundeRowS.kundeNr + "");
>                     // Mark row as modified.
>                     kundeRowS.SetModified();
>                     kunderT.ImportRow(kundeRowS);
>                 }
>  
>                 Console.WriteLine("s: " + kunderS.Count.ToString());
>                 Console.WriteLine("t: " + kunderT.Count.ToString());
> 
>                 kundeAdapterT.FillVrsKunder(kunderT);
> 
> Target table is residing in MSDE. 
> Count of s returns the count of records to add. 
> Count of t returns existing records + count of records to add.
> 
> What am I missing?
> 
> /gustav
> 
> 
> >>> stuart at lexacorp.com.pg 05-02-2008 00:06:55 >>>
> Do you mean have the user physically browse through the rows looking for specific records?
> 
> If that is the case, I would probably go with a DatagridView bound to the source data.
> When the user selects a row (double click, highlight and click a button or whatever), read the 
> row data and feed it to a TableAdapter.Insert on the target table.
> 
> 
> On 4 Feb 2008 at 18:41, Gustav Brock wrote:
> 
> > Hi all
> > 
> > I have created two tableadapters, a source and a target, and need to
> > browse through the source looking for rows and, when a row meeting
> > some conditions is found, copy this to the target. What is the best
> > method? 
> > 
> > /gustav





More information about the dba-VB mailing list