- Код: Выделить всё
Dim col As New Column
col.Name = colName
col.Attributes = adColNullable
oCat.Tables(fieldName).Columns.Append col
И можно ли это как-то сразу распространить на всю базу, например при ее создании?
Dim col As New Column
col.Name = colName
col.Attributes = adColNullable
oCat.Tables(fieldName).Columns.Append col
CREATE TABLE Prises (PrisID COUNTER CONSTRAINT PrisID_pk PRIMARY KEY, PrisPort TEXT(50), PrisStop SINGLE, PrisAmount DOUBLE, PrisUe TEXT(10), PrisMemo MEMO, PrisDate DATE)
Public Sub newIndex(dbTable As ADOX.Table)
' dbTable is table where we add new index
Dim dbIndex As ADOX.Index
On Error GoTo errCatch
Set dbIndex = New ADOX.Index
dbIndex.name = "tblPrimaryIndex"
dbIndex.Clustered = True
dbIndex.IndexNulls = adIndexNullsDisallow
dbIndex.PrimaryKey = True
dbIndex.Unique = True
dbIndex.Columns.Append "id_Column"
' id_Column is a name of column
dbTable.Keys.Append dbIndex
dbTable.Indexes.Append "column2Index", "newColumn2"
' newColumn2 is name of column in our table
Exit Sub
errCatch:
MsgBox Err.Description & Err.Number
End Sub
CREATE TABLE Prises (
PrisID COUNTER PRIMARY KEY,
PrisPort TEXT(50),
PrisStop SINGLE,
PrisAmount DOUBLE,
PrisUe TEXT(10),
PrisMemo MEMO,
PrisDate DATE
)
Dim oTable As New Table
oTable.Name = TableName
oCat.Tables.Append oTable
oCat.Tables(TableName).Columns.Append ColunmName
Set idx = New ADOX.Index
With idx
.Name = "Index1"
.Columns.Append ColunmName
.Unique = True
End With
oCat.Tables(TableName).Indexes.Append idx
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 56