[newbie] SQL question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

in one of my programs I am connected to a database by Jet. Now, I'm looking for a SQL statement, that does the following
1. Gets every recored in a table of the db I'm conntected to (SELECT * FROM tablename, I suppose
2. Appends this whole stuff to a specific table of a specific database (filename and exact path are known)

Can anyone propose a SQL statement for this

Thanks a lo
Gordon
 
Hi Gordon:

Here's an example on how to do it, but I'll walk you through it here.
http://www.knowdotnet.com/articles/datasetmerge.html
Configure two dataadapters. One of them you just need a Select statement
configured.. use the source table you reference ...FROM TableName). Now, on
this dataadapter, set the AcceptChangesDuringFill property to false.

Now, configure another one using the destination table... and make sure it
has a valid update command and that it's schema matches the first table.
This table can have more fields than the first, but it's best that they
match. To be safe, only inlude fields in your query witht he first adatper
that appear in the destination table of the second.

Basically itd' be SELECT field1, field2, field3 FROM SourceTable

Then INSERT INTO DestinationTable (field1, field2, field3) VALUE (@First,
@Second, @Third).

Ok, so just call fill with the first dataadapter.. as soon as it's filled,
(assuming you don't want to modify the data) call DataAdapter2.Update with
the same datatable and dataset:

daSource.Fill(dsTable, "dtTable")
//Make sure you set AcceptChangesDuringFill to false on the first adapter
(daSource) before calling Fill
daDestination.Update(dsTable, "dtTable")

This should do it for you but let me know if you have any problems.

Cheers,

Bill
Gordon Knote said:
Hi,

in one of my programs I am connected to a database by Jet. Now, I'm
looking for a SQL statement, that does the following:
1. Gets every recored in a table of the db I'm conntected to (SELECT * FROM tablename, I suppose)
2. Appends this whole stuff to a specific table of a specific database
(filename and exact path are known).
 
Back
Top