VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "Indexer"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Attribute VB_Ext_KEY = "SavedWithClassBuilder" ,"Yes"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
Option Explicit
'Klasa Indexer
'Pozwala tworzyć nowe tabele
'Dodawać do nich kolumny
'I tworzyć indeksy
'Wykorzystuje ADOX
Private tb As Table
Private db As Connection
Private cat As Catalog
'--------
Public Sub makeTable(ctg As Catalog, nm As String)
  Set cat = ctg                   'Pobierz instancję Catalog
  Set tb = New Table              'Utwórz instancję klasy Table
  tb.Name = nm
End Sub
'--------
Public Sub openTable(ctg As Catalog, nm As String)
  Set cat = ctg
  Set tb = cat.Tables.Item(nm)
End Sub
'--------
Public Sub addTable()
  cat.Tables.Append tb
End Sub
'--------
Public Sub createKey(nm As String)
  Dim indx As New Index
  Dim colm As New Column
  colm.Name = nm
  colm.Type = adInteger
  Set colm.ParentCatalog = cat
  colm.Properties("AutoIncrement") = True
  tb.Columns.Append colm
  indx.Name = nm & "_" & "Index"
  indx.PrimaryKey = True
  indx.Columns.Append nm, adInteger, 20
  indx.Unique = True
  tb.Indexes.Append indx
End Sub
'--------
Public Sub createText(nm As String, length As Integer)
  Dim tx As New Column
  tx.Name = nm
  tx.DefinedSize = length
  tx.Type = adWChar
  tb.Columns.Append tx, adWChar, length
End Sub
'--------
Public Sub createDateField(nm As String)
  Dim dt As New Column
  dt.Type = adDate
  dt.Name = nm
  tb.Columns.Append dt
End Sub
'--------
Public Sub createCurrency(nm As String)
  Dim c As New Column
  c.Type = adCurrency
  c.Name = nm
  tb.Columns.Append c
End Sub
'--------
Public Sub makeIndex(nm As String, primary As Boolean)
  Dim ind As New Index
  ind.Name = nm
  ind.PrimaryKey = primary
  ind.Columns.Append nm
  tb.Indexes.Append ind
End Sub
'--------
Public Sub createLong(nm As String)
  Dim dt As New Column
  dt.Name = nm
  dt.Type = adLongVarBinary
  tb.Columns.Append dt
End Sub
'--------
Public Sub createInteger(nm As String)
  Dim dt As New Column
  dt.Name = nm
  dt.Type = adInteger
  tb.Columns.Append dt
End Sub
'--------
Public Sub createSingle(nm As String)
  Dim dt As New Column
  dt.Name = nm
  dt.Type = adSingle
  tb.Columns.Append dt, adSingle, 4
End Sub
'--------
Public Sub createBoolean(nm As String)
  Dim dt As Column
  dt.Name = nm
  dt.Type = adBoolean
  tb.Columns.Append dt, adBoolean
End Sub

