Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Add fields with ADOX


Message #1 by =?iso-8859-1?Q?Gonzalo_Ruiz_de_Villa_Su=E1rez?= <gonzalo.ruizdevilla@a...> on Fri, 19 Jan 2001 11:44:27 +0100
I want to add a field to an access table using ADOX.

Do you have any examples of how to do this?



Thanks



Gonzalo Ruiz de Villa Suárez

Adesis Netlife

Tel. (+34) 915 699 113

Fax. (+34) 915 655 050

e-mail: gonzalo.ruizdevilla@a...

URL: http://www.adesis.com







Message #2 by John Pirkey <mailjohnny101@y...> on Fri, 19 Jan 2001 06:54:16 -0800 (PST)
try this:



Dim TargetCat As ADOX.Catalog

Dim TrgTbl    As ADOX.Table

Dim oColumn   As ADOX.Column

 

'open your connection

Set TargetCat = New ADOX.Catalog

 

TargetCat.ActiveConnection = "your connecion string here"

 

'get the table you want to add columns to

Set TrgTbl = TargetCat.Tables("TableName")

 

'now build your column object to append

Set oColumn = New ADOX.Column

 

With oColumn

   .Name = "MyNewColumn"

   .Type = <data type constant here> (adInt, adVarWChar, etc)

   .DefinedSize = <how long? - not needed if a numeric type is used.>

End With

 

TrgTbl.Columns.Append oColumn

 

Set TrgTbl = Nothing

Set oColumn = Nothing

Set TargetCat = Nothing



hope this helps,



john



--- Gonzalo_Ruiz_de_Villa_Suárez <gonzalo.ruizdevilla@a...> wrote:

> I want to add a field to an access table using ADOX.

> Do you have any examples of how to do this?

> 

> Thanks

> 

> Gonzalo Ruiz de Villa Suárez

> Adesis Netlife

> Tel. (+34) 915 699 113

> Fax. (+34) 915 655 050

> e-mail: gonzalo.ruizdevilla@a...

> URL: http://www.adesis.com


  Return to Index