Russian version
English version
| | | | SILICON TAIGA | ISDEF | CD | | | | | | | |
 
 
 
IT-
 
 
 
RSS-

ADOX ACCESS

osmor

ADOX MS ACCESS (MDB)

C ADO DAO, ACCESS , DAO ? ?
.

, , MSDN.

ADOX - Microsoft ActiveX Data Objects Extensions for Data Definition Language and Security.

, ADO Data Definition Language (DDL - ), .

ADOX, , ADOX ACCESS.

, ADOX , , , , , ACCESS.
ADOX , , , ACCESS.

ADOX :

[Image]

MSDN:
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado/html/2fa6237b-44b8-4b6c-9952-5acd80a54e20.asp)

.

ADOX , , Catalog, MSA :

1. "Microsoft ADO Ext. 2.8 for DDL and Security" ( ), :

  • "Tools-References"
  • "Microsoft ADO Ext. 2.8 for DDL and Security"
  • ""
  • " "

Catalog :
DimadoxCatAsADOX.Catalog
SetadoxCat=NewADOX.Catalog

:
DimadoxCatAs New ADOX.Catalog

( )

2. Catalog CreateObject. , , ADOX, . , Catalog :

DimadoxCatAsObject
SetadoxCat=CreateObject("ADOX.Catalog")

, , . ActiveConnection, ADODB.Connection .
, :

Set adoxCat.ActiveConnection = CurrentProject.Connection
( Connection)


adoxCat.ActiveConnection = CurrentProject.Connection
( Connection)

adoxCat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & CurrentProject.FullName
( )

, , . ADOX.Catalog, , ACCESS.

( , , ):

OptionCompareDatabase
OptionExplicit



PublicSubADOXListTables()

DimadoxCatAsADOX.Catalog
DimadoxTblAsADOX.Table
DimstrTypeAsString
SetadoxCat=NewADOX.Catalog

'
adoxCat.ActiveConnection=CurrentProject.Connection
'TYPETable
ForEachadoxTblInadoxCat.Tables
SelectCaseadoxTbl.Type
Case"LINK"'JET
strType="-JET"
Case"TABLE"'
strType="-"
Case"ACCESSTABLE"'ACCESS
strType="-MSA"
Case"SYSTEMTABLE"'JET
strType="-JET"
Case"PASS-THROUGH"'ODBC
strType="-ODBC"
CaseElse'-
strType="--"
EndSelect
Debug.PrintadoxTbl.Name;strType
Next
SetadoxCat=Nothing
SetadoxTbl=Nothing
EndSub



PublicSubADOXCreateLinkTable(strFileNameAsString,_
strTblNameAsString,_
OptionalstrLinkTblNameAsString="")
'MSACCESS
'strFileName-ĠACCESS,
'strTblName-
'strLinkTblName-,
'strLinkTblName,strFileName
DimadoxCatAsADOX.Catalog
DimadoxTblAsNewADOX.Table
DimstrTypeAsString
SetadoxCat=NewADOX.Catalog
'
adoxCat.ActiveConnection=CurrentProject.Connection
IfstrLinkTblName=""ThenstrLinkTblName=strTblName
WithadoxTbl
.ParentCatalog=adoxCat
.Name=strLinkTblName'
'
.Properties("JetOLEDB:LinkDatasource").Value=strFileName
'
.Properties("JetOLEDB:RemoteTableName").Value=strTblName
.Properties("JetOLEDB:CreateLink").Value=True
EndWith
adoxCat.Tables.AppendadoxTbl'
SetadoxCat=Nothing
SetadoxTbl=Nothing

EndSub



PublicSubADOXRefreshLinks(strFileNameAsString)
'MSACCESS
'strFileName-ĠACCESS,
DimadoxCatAsADOX.Catalog
DimadoxTblAsADOX.Table

SetadoxCat=NewADOX.Catalog
adoxCat.ActiveConnection=CurrentProject.Connection

ForEachadoxTblInadoxCat.Tables
',JET
IfadoxTbl.Type="LINK"Then
adoxTbl.Properties("JetOLEDB:LinkDatasource")=strFileName
EndIf
Next
SetadoxCat=Nothing
SetadoxTbl=Nothing
EndSub



PublicSubADOXCreateTable()
'tblOrders:
'idOrder-,
'NumOrder-,12,
'dtOrder-,Date()
'
DimadoxCatAsADOX.Catalog
DimadoxTblAsNewADOX.Table
DimadoxColAsADOX.Column
SetadoxCat=NewADOX.Catalog
'
adoxCat.ActiveConnection=CurrentProject.Connection

WithadoxTbl
.Name="tblOrders"'
'Column()
SetadoxCol=NewADOX.Column
WithadoxCol
.ParentCatalog=adoxCat'
.Name="id"'
.Type=adInteger'
.Properties("AutoIncrement").Value=True'
EndWith
.Columns.AppendadoxCol,adInteger'
'
.Keys.Append"PrimaryKey",adKeyPrimary,"id"

'
'堹
SetadoxCol=NewADOX.Column
WithadoxCol
.ParentCatalog=adoxCat
.Name="NumOrder"
.Type=adVarWChar'
.DefinedSize=12
.Properties("Description").Value=""
'
.Properties("JetOLEDB:ColumnValidationRule").Value="<>''andnotisnull"
'
.Properties("JetOLEDB:ColumnValidationText").Value=""
EndWith
.Columns.AppendadoxCol,adVarWChar

'
SetadoxCol=NewADOX.Column
WithadoxCol
.ParentCatalog=adoxCat
.Name="dtOrder"
.Type=adDate'
.Properties("Description").Value=""
.Properties("Default").Value="date()"'
EndWith
.Columns.AppendadoxCol,adDate


'
adoxCat.Tables.AppendadoxTbl

EndWith
SetadoxCat=Nothing
SetadoxTbl=Nothing
SetadoxCol=Nothing

EndSub


PublicSubADOXListIndexTbl(strTblNameAsString)
'++
'
'strTblName-
DimadoxCatAsADOX.Catalog
DimadoxTblAsADOX.Table
DimadoxInxAsADOX.Index
DimadoxColAsADOX.Column
SetadoxCat=NewADOX.Catalog
adoxCat.ActiveConnection=CurrentProject.Connection

SetadoxTbl=adoxCat.Tables(strTblName)
ForEachadoxInxInadoxTbl.Indexes
WithadoxInx
Debug.Print"_________________________________"
Debug.Print"-";.Name
Debug.Print"-";.PrimaryKey
Debug.Print"-";.Unique
Debug.Print":";
ForEachadoxColIn.Columns
Debug.PrintadoxCol.Name;";";
Next
Debug.Print
EndWith
Next

EndSub


.
Access View Procedure, ADOX . Select Views, ( Select c ) Procedures.
, , "" MS ACCESS .

, , Procedures.
http://support.microsoft.com/default.aspx?scid=kb;en-us;252888
, ACCESS 2000:
http://support.microsoft.com/default.aspx?scid=kb;en-us;246213

PublicSubADOXListQuerys()
'
DimadoxCatAsADOX.Catalog
DimiAsInteger
SetadoxCat=NewADOX.Catalog
'
adoxCat.ActiveConnection=CurrentProject.Connection
WithadoxCat
Debug.Print"Views"
If.Views.Count=0Then
Debug.Print"View"
Else
Fori=0To.Views.Count-1
Debug.Print.Views(i).Name
Next
EndIf
Debug.Print"Procedures"
If.Procedures.Count=0Then
Debug.Print"Procedures"
Else
Fori=0To.Procedures.Count-1
Debug.Print.Procedures(i).Name
Next
EndIf
EndWith
EndSub


PublicSubADOXcreateQuery()
'
DimadoxCatAsADOX.Catalog
DimqdfAsADODB.Command
SetadoxCat=NewADOX.Catalog
adoxCat.ActiveConnection=CurrentProject.Connection
'Command
Setqdf=NewADODB.Command
'
qdf.CommandText="select*fromtblOrders"
'
adoxCat.Views.Append"",qdf
EndSub

, , .


     [1]  
 
 
  : 14.04.2006  

| | | | SILICON TAIGA | ISDEF | CD | | | | | | | |

: Silicon Taiga    
Rambler's Top100 Rambler's Top100