Create tabledefinitions and drop tables by code

  • Thread starter Screaming Eagles 101
  • Start date
S

Screaming Eagles 101

Hi, can anyone help me with the correct statements
to copy a table(design), so a new table with just the skeleton of an
existing table,
and also how to drop an existing table ?

I need this code for use in a VB.NET 2005 program...

Thanks

--
Filip
http://www.ww2airborne.net/
Official Site of the 101st Airborne - 463rd PFA
skype: airborne463pfa-fiwi
-------------------------------------------------

Earlier request in the dotnet newsgroup :

Do some searches in the comp.databases.ms-access newsgroup for "create
tables." After you have some sample code just add a reference to access
and .Net and you should be set.

Thanks,

Seth Rowe

Hi,

I have an Access MDB database with a Table1.
From VBNET I would like to CREATE a NEW table, which is a copy of Table1,
but not with the Data, only the definition.
I would also like to have the possibility to DROP a table in that
Database.
 
B

Brendan Reynolds

You can drop a table easily by executing the SQL statement "DROP Table
YourTableName".

You can create a table using the SQL command "CREATE TABLE", but JET SQL
doesn't provide a means of creating a new table based on the schema of an
existing table. In VBA or VB 'classic' we would use DAO or ADOX to do
something like that. These are COM components, and you could use them from a
VB.NET app via COM Interop, but I am not at all convinced that this would be
the right way to go in a .NET app. My advise is to try asking again in
another .NET forum. Try microsoft.public.dotnet.framework.adonet.
 
G

Guest

SELECT Table1.* INTO Table2
FROM Table1
WHERE 1 = 2;

Within Access the above statement will create an empty Table2 with all the
fields from Table1; however, it won't include anything like indexes, primary
keys, default values, etc.

USAF to the rescue again! ;-)
 
S

Screaming Eagles 101

Thanks, I'll try that !
P.S. USAF all right, as long as it's a P51 Mustang... :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top