Hello Everybody, I received support with the ADOX API reference
address, in the same time I was coding a routine to modify the name of a
column using ADOX (i send it ), I have some problems:
Restoring indexes of the table (adox.indexes) if i try to rename a primary
key field the code work but if i open the table with the update made
Access 2000 ask me a parameter like:
nametable.the_name_that_i_try_to_rename
1)I try to check all the property in the adox.table before and after my test
but i am not able to find any property with the name that access ask me.
2) Could i send the order of the new column with adox, for exemple if i try
to append a new colum is possible to put it in the first position of the
access table structure ?
I hope you understand my English...
With best regards
thank you,
Piva Giancarlo.
'########################################################################## Public colI As Collection Public Sub Modify_Column(ByRef MyCnn As ADODB.Connection, _ Dim Col As ADOX.Column strTempName = MyColName & "_tmpFM" Set Catalog.ActiveConnection = MyCnn '(GP) Verifico la presenza di indici li salvo _ '########################################################################## '########################################################################## With Table For Each Col In Cols '(GP)Verifico se il nome campo passato corrisponde _ If Col.Name = MyColName Then MyXcol.Name = strTempName If Col.Properties(0).Value = False Then '(GP)Store data into array... '###################################################################### Set MyRecordset = New ADODB.Recordset MyRecordset.MoveFirst I = 0 End If End If '###################################################################### 'MyXcol.Attributes = Case "Autoincrement" If Col.Properties(I).Value = False Case "Default" If Not Case "Description" If Col.Properties(I).Value <> "" Case "Nullable" If Col.Properties(I).Value = False Case "Fixed Length" If Col.Properties(I).Value = False '***************************************************** 'Case "Seed" ' If IsCounter = True Then 'Case "Increment" ' If IsCounter = True Then '***************************************************** If Col.Properties(I).Value <> "" Case "Jet OLEDB:Column Validation Rule" If Col.Properties(I).Value <> "" Case "Jet OLEDB:IISAM Not Last Column" If Col.Properties(I).Value = False Case "Jet OLEDB:AutoGenerate" If Col.Properties(I).Value = False read more »
####################
Public Temp As New ADOX.Index
Public Catalog As New ADOX.Catalog
MyTblName As String, _
MyColName As String, _
MyNewColName As String, _
Optional MyLen As Long)
Dim Cols As ADOX.Columns
Dim Grp As ADOX.Group
Dim Grps As ADOX.Groups
Dim Ndx As New ADOX.Index
Dim Ndxs As ADOX.Indexes
Dim Key As ADOX.Key
Dim Keys As ADOX.Keys
Dim Proc As ADOX.Procedure
Dim Procs As ADOX.Procedures
Dim Prop As ADOX.Property
Dim Props As ADOX.Properties
Dim Table As ADOX.Table
Dim Tables As ADOX.Tables
Dim User As ADOX.User
Dim Users As ADOX.Users
Dim View As ADOX.View
Dim Views As ADOX.Views
Dim MyXcol As New ADOX.Column
Dim ThisIndex As New ADOX.Index
Dim MyRecordset As ADODB.Recordset
Dim MyArray() As Variant
Dim IsCounter As Boolean
Dim I As Integer
Dim n As Integer
Dim a As Integer
Dim iFile As Integer
Dim sFile As String
Dim strTempName As String
Set Tables = Catalog.Tables
Set Table = Tables(MyTblName)
Set colI = New Collection
in nella collezione ColIndexes e li rimuovo...
##############
For I = 0 To Table.Indexes.Count - 1
If Left$(Table.Indexes(I).Name, 2) <> "s_" Then
Set ThisIndex = Table.Indexes(I)
RecordIndexInfo Table.Indexes(I), colI
Set ThisIndex = Nothing
End If
Next
'Elimino...
Do While Table.Indexes.Count > 0 ' Inner loop.
Table.Indexes.Delete Table.Indexes(0).Name
Loop
##############
.Name = MyTblName
Set Cols = Tables(MyTblName).Columns
ad un campo realmente esistente...
MyXcol.Type = Col.Type
MyXcol.NumericScale = Col.NumericScale
MyXcol.DefinedSize = Col.DefinedSize + MyLen
MyXcol.ParentCatalog = Catalog
IsCounter = False
ElseIf Col.Properties(0).Value = True Then
IsCounter = True
End If
If Not IsCounter Then
MyRecordset.Open MyTblName, MyCnn, adOpenKeyset,
, adCmdTable
ReDim MyArray(MyRecordset.RecordCount)
If MyRecordset.RecordCount > 0 Then
Do Until MyRecordset.EOF
MyArray(I) =
MyRecordset.Fields(MyColName).Value
MyRecordset.MoveNext
I = I + 1
Loop
I = 0
MyRecordset.Close
.Columns.Item(MyColName).Attributes '(GP)NOT USED...
For I = 0 To Col.Properties.Count - 1
Select Case Col.Properties(I).Name
Then
MyXcol.Properties(I).Value =
False
ElseIf Col.Properties(I).Value =
True Then
MyXcol.Properties(I).Value =
True
End If
IsEmpty(Col.Properties(I).Value) Then
'inserire controllo sul type col...
etc.etc...
Else
MyXcol.Properties(I).Value =
Empty
End If
Then
MyXcol.Properties(I).Value =
CStr(Col.Properties(I).Value)
Else
MyXcol.Properties(I).Value = ""
End If
Then
MyXcol.Properties(I).Value =
False
ElseIf Col.Properties(I).Value =
True Then
MyXcol.Properties(I).Value =
True
End If
Then
MyXcol.Properties(I).Value =
False
ElseIf Col.Properties(I).Value =
True Then
MyXcol.Properties(I).Value =
True
End If
' SI POSSONO SETTARE SOLO DOPO L' APPEND
...
' MyXcol.Properties(I).Value =
CInt(Col.Properties(I).Value)
' Else
' MyXcol.Properties(I).Value = 1
' End If
' MyXcol.Properties(I).Value =
CInt(Col.Properties(I).Value)
' Else
' MyXcol.Properties(I).Value = 1
' End If
Case "Jet OLEDB:Column Validation Text"
Then
MyXcol.Properties(I).Value =
CStr(Col.Properties(I).Value)
Else
MyXcol.Properties(I).Value = ""
End If
Then
MyXcol.Properties(I).Value =
CStr(Col.Properties(I).Value)
Else
MyXcol.Properties(I).Value = ""
End If
Then
MyXcol.Properties(I).Value =
False
ElseIf Col.Properties(I).Value =
True Then
MyXcol.Properties(I).Value =
True
End If
Then
MyXcol.Properties(I).Value =
False
ElseIf Col.Properties(I).Value =
True Then
MyXcol.Properties(I).Value =
True
End If
...