Add a column to a table using ADO

D

dave

I need to add a column to a table using ADO.

The following works, but only for a new table. How should I change this to
alter an existing table?


Dim strConn
Dim Catalog As New ADOX.Catalog
Dim Table As ADOX.Table

Set Catalog = New ADOX.Catalog

strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Data.mde"
Catalog.ActiveConnection = strConn

Set Table = New ADOX.Table
Table.Name = "tblExistingTable"
Table.Columns.Append "NewColumn", adBoolean
Catalog.Tables.Append Table
 
R

Ron Weiner

Why not use a Data Definition Language query from code like:

docmd.Runsql "alter table [tblExistingTable] add column [NewColumn] yesno"

Should work OK.

Ron W
 

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