Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rename column - ADO or SQL??

Status
Not open for further replies.

briglass

Programmer
Dec 4, 2001
179
GB
How do I rename a column's name in an access database from within visual basic, using ADO or SQL?

Thanks,
Brian
 
For ADO - a little extra code if you want to set up a test.

Function catalogInfo()
'-- set reference to ADOX library
'- Microsoft ADO Ext. 2.6 for DDL and Security
'-- Microsoft ActiveX data objects 2.6 library also needed for ADO

Dim cg As New ADOX.Catalog
Dim tb As New ADOX.Table
Dim cn As ADODB.Connection
Dim cl As ADOX.Column
Set cg.ActiveConnection = CurrentProject.Connection

'-Add a table
''tb.Name = "Test"
''tb.Columns.Append "col1", adInteger
''tb.Columns.Append "col2", adVarWChar, 50
''Debug.Print "table = "; cg.Tables("Test").Name
''cg.Tables.Append tb
''Exit Function
'-Rename a column
Set tb = cg("test")
Set cl = tb("col2")
cl.Name = "col2aa"
'-It is done

Exit Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top