Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
With ADO change a field (column) name in Access 2000
Message
 
À
06/03/2003 00:19:42
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00761980
Message ID:
00762009
Vues:
21
>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform