table copying in ado 2.0

  • Thread starter Thread starter ray well
  • Start date Start date
R

ray well

i need to copy in code a table from a legacy dbase III file into an access
mdb file.

both source and destination tables have the same table names, field names,
field types, & field sizes.

the access table has an index attached to it, and starts with a empty table.

i want to avoid having to create & copy row by row from the source to the
destination table

i can copy the source table into a table with the following code. i can read
the real data from that table

--------------------------
sSqlSource = "SELECT Info.* FROM Info;"
DaSource = New OleDb.OleDbDataAdapter(sSqlSource,
DBFConnedctionToSource)
Dim t As New DataTable()
DaSource.Fill(t)
--------------------------

i open the destination table with the following code, the table is empty,
but has a index attached to itself inside the mdb file
-----------------------------
sSqlDestination = "SELECT Info.* FROM Info;"
DaDestination = New OleDb.OleDbDataAdapter(sSqlDestination,
DBFConnedctionToDestination)
DsDestination.Clear()
Dim cbDestinationDa As New OleDb.OleDbCommandBuilder(DaDestination)
DaDestination.Fill(DsDestination, "Info")
-------------------------------
i don't know how to structure the 'DaDestination.Update' code

i tired 'DaDestination.Update(t)', it executes with NO ERROR, but doesn't do
anything, no data gets copied

any idea how to get the table to copy to the destination? i would appreciate
a bit of code.


thanks for any help
ray
 
sSqlDestination = "SELECT Info.* FROM Info;"
DaDestination = New OleDb.OleDbDataAdapter(sSqlDestination,
DBFConnedctionToDestination)
DsDestination.Clear()
Dim cbDestinationDa As New OleDb.OleDbCommandBuilder(DaDestination)
DaDestination.Fill(DsDestination, "Info")


this isn't going to put data into your destination table. It only creates a
table called "info" in dsDestination. You have to loop through your DBF
table (the table your filled with the source data) row by row to fill
(DsDestination, "Info"). Then you can run

DaDestination.Update(DsDestination, "Info")

and that will populate the "Info" table in the Access mdb. I don't know how
to copy data from one .Net table to another .Net table except by looping.
Maybe someone knows how to do it Fill style (that would be better) - I just
only know how to do it the looping way. But the main thing is that you have
to get the data from the source .Net table to the destination .Net table in
order to get the data to your intended destination.

You can fill a .Net table from external data. And you can also pass data
between external tables if they reside on the same system as follows:

Insert Into server2.DB2.dbo.tbl2 Select * from server1.DB1.dbo.tbl1

But DBF to Access is 2 different DB systems. I don't know if the above
Insert statement would work on 2 different systems. Maybe if they are both
OleDB's. But if one is a sqlTable and one is an Ole table, then you will
need a source .Net table and a destination .Net table to act as a bridge
between the two systems.

Rich
 
rich,

i did it by looping and it works, but i wanted to know if i could make it
faster. ray
 
dude

open up Accesss MDB and right click IMPORT?

are you some sort of frigging retard or something?

-PFC Sadr
 
Back
Top