Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
With ADO change a field (column) name in Access 2000
Message
 
To
06/03/2003 00:19:42
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00761980
Message ID:
00762009
Views:
22
>Does anyone know the way, how to change a field name in access database (.mdb) with a ADO connection?

Hi,
lcMDBPath = "C:\test.mdb"
lcMDBStr = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" + lcMDBPath + ";"

oCat = Create("adox.Catalog")
oCn = Create("adodb.Connection")
oCn.Open(lcMDBStr)
oCat.ActiveConnection = oCn
oCat.Tables("SomeTable").Columns("SomeField").Name = "NewName"
oCn.Close()
You could also rename column using Connection.Execute() method, but because of SQL command ALTER TABLE ... RENAME COLUMN is not supported by Access, you'll need to add a new column, copy data from old column to a new one, and drop old column.

HTH,
Alexander
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform