Copy a Table using ADO or ADOX 
Author Message
 Copy a Table using ADO or ADOX

Hi does anybody know a smart and easy way to make a copy of a table.
I want the copy of the table to be in the same database as the original
table, just with a new name.

I'm using VB and ADO for my data access. The database is an Access Database
and I have seen that in the Access application it is possible to copy a
table.

Say the old database has these tables:

Authors  with  8 records
Publishers with 30 records

Now I would like to have a copy of Publishers called PubCopy like this:

Authors  with  8 records
Publishers with 30 records
PubCopy with 30 records

Perhaps its simple but can you help me? How do I copy the table, in code,
runtime?

BR Lars Iversen



Fri, 22 Aug 2003 22:41:18 GMT
 Copy a Table using ADO or ADOX

set db = New Connection
db.Open "Provider=..."

db.Execute "SELECT Publishers.* INTO PubCopy FROM Publishers"

But this method not create indexes and keys
--
Verbovsky Innokenty
ICQ 16999735

Quote:
> Hi does anybody know a smart and easy way to make a copy of a table.
> I want the copy of the table to be in the same database as the original
> table, just with a new name.

> I'm using VB and ADO for my data access. The database is an Access
Database
> and I have seen that in the Access application it is possible to copy a
> table.

> Say the old database has these tables:

> Authors  with  8 records
> Publishers with 30 records

> Now I would like to have a copy of Publishers called PubCopy like this:

> Authors  with  8 records
> Publishers with 30 records
> PubCopy with 30 records

> Perhaps its simple but can you help me? How do I copy the table, in code,
> runtime?

> BR Lars Iversen



Sat, 23 Aug 2003 02:51:21 GMT
 Copy a Table using ADO or ADOX
After creating PubCopy you can do:
db.Execute "ALTER TABLE PubCopy ADD " & _
"CONSTRAINT [PrimaryKey] PRIMARY KEY NONCLUSTERED " & _
"( [PublisherID] )"

--
Verbovsky Innokenty
ICQ 16999735

Quote:
> set db = New Connection
> db.Open "Provider=..."

> db.Execute "SELECT Publishers.* INTO PubCopy FROM Publishers"

> But this method not create indexes and keys
> --
> Verbovsky Innokenty
> ICQ 16999735


> > Hi does anybody know a smart and easy way to make a copy of a table.
> > I want the copy of the table to be in the same database as the original
> > table, just with a new name.

> > I'm using VB and ADO for my data access. The database is an Access
> Database
> > and I have seen that in the Access application it is possible to copy a
> > table.

> > Say the old database has these tables:

> > Authors  with  8 records
> > Publishers with 30 records

> > Now I would like to have a copy of Publishers called PubCopy like this:

> > Authors  with  8 records
> > Publishers with 30 records
> > PubCopy with 30 records

> > Perhaps its simple but can you help me? How do I copy the table, in
code,
> > runtime?

> > BR Lars Iversen



Sat, 23 Aug 2003 03:01:12 GMT
 Copy a Table using ADO or ADOX
You can also create the query in access that copys the table and then run it
from your VB app just like  a stored procedure in other databases.


Quote:
> Hi does anybody know a smart and easy way to make a copy of a table.
> I want the copy of the table to be in the same database as the original
> table, just with a new name.

> I'm using VB and ADO for my data access. The database is an Access
Database
> and I have seen that in the Access application it is possible to copy a
> table.

> Say the old database has these tables:

> Authors  with  8 records
> Publishers with 30 records

> Now I would like to have a copy of Publishers called PubCopy like this:

> Authors  with  8 records
> Publishers with 30 records
> PubCopy with 30 records

> Perhaps its simple but can you help me? How do I copy the table, in code,
> runtime?

> BR Lars Iversen



Tue, 02 Sep 2003 01:59:59 GMT
 Copy a Table using ADO or ADOX
But using:
db.Execute "CREATE TABLE PubCopy AS SELECT * from Publishers" should.

Nigel W


Quote:
> After creating PubCopy you can do:
> db.Execute "ALTER TABLE PubCopy ADD " & _
> "CONSTRAINT [PrimaryKey] PRIMARY KEY NONCLUSTERED " & _
> "( [PublisherID] )"

> --
> Verbovsky Innokenty
> ICQ 16999735


> > set db = New Connection
> > db.Open "Provider=..."

> > db.Execute "SELECT Publishers.* INTO PubCopy FROM Publishers"

> > But this method not create indexes and keys
> > --
> > Verbovsky Innokenty
> > ICQ 16999735


> > > Hi does anybody know a smart and easy way to make a copy of a table.
> > > I want the copy of the table to be in the same database as the
original
> > > table, just with a new name.

> > > I'm using VB and ADO for my data access. The database is an Access
> > Database
> > > and I have seen that in the Access application it is possible to copy
a
> > > table.

> > > Say the old database has these tables:

> > > Authors  with  8 records
> > > Publishers with 30 records

> > > Now I would like to have a copy of Publishers called PubCopy like
this:

> > > Authors  with  8 records
> > > Publishers with 30 records
> > > PubCopy with 30 records

> > > Perhaps its simple but can you help me? How do I copy the table, in
> code,
> > > runtime?

> > > BR Lars Iversen



Tue, 02 Sep 2003 20:02:16 GMT
 
 [ 5 post ] 

 Relevant Pages 

1. How display tables from database using ADO or ADOX

2. Setting Access 97 Table Column properties using ADo/ADOX

3. Using ADO 2.1 / ADOX / ADO 2.0 with C++

4. Using ADO 2.1 / ADOX / ADO 2.0 with C++

5. ADO or ADOX creating a new table from a table template

6. Copy a table using ADO

7. Copy field using ADOX?

8. Copy table using ADO

9. Adox and copy table

10. adox's table copy errro..

11. Copying Tables with ADOX

12. Create any desktop database using ADOX/ADO


 
Powered by phpBB® Forum Software