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] [mad] [mad]](/data/assets/smilies/mad.gif)
Anything is possible, the problem is I only have one lifetime.![[thumbsup2] [thumbsup2] [thumbsup2]](/data/assets/smilies/thumbsup2.gif)
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] [mad] [mad]](/data/assets/smilies/mad.gif)
Anything is possible, the problem is I only have one lifetime.
![[thumbsup2] [thumbsup2] [thumbsup2]](/data/assets/smilies/thumbsup2.gif)