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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax for DDL using ADODC and VB

Status
Not open for further replies.

Foada

Programmer
Feb 4, 2002
1,110
US
I am trying to write a utility that verifies an Access 2000 database. I am able to get the ALTER TABLE to add a column but not to rename it as follows:

Private Sub MySub()

On Error GoTo ErrHandler

hDB.ConnectionString = sDBConnection & App.Path & "\TestDB.mdb"
hDB.Mode = adModeReadWrite
hDB.Open


'This line works
hDB.Execute ("Alter Table myTable Add Column newColumn Char(50)")

'This line does not
hDB.Execute ("Alter Table myTable Rename oldName To newName")

If hDB.State Then
hDB.Close
End If

Exit Sub

ErrHandler:
Debug.Print "Err : " & Err.Description & Err.Number
For Each errDB In hDB.Errors
Debug.Print "Collection : " & errDB.Description & errDB.SQLState & errDB.NativeError
Next
Resume Next
End Sub

The ALTER TABLE RENAME does not even generate a trappable error it just kicks out a Runtime error that there is a syntax error in the ALTER TABLE statement. I checked with MSDN and it claims that the syntax is correct. Any ideas?[mad]
Anything is possible, the problem is I only have one lifetime.[thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top