Microsoft KB Archive/249718: Difference between revisions
(importing KB archive) |
m (Text replacement - """ to """) |
||
Line 47: | Line 47: | ||
== SUMMARY == | == SUMMARY == | ||
The ActiveX Data Objects (ADO) Connection object's '''OpenSchema''' method allows programmatic access to metadata about various database containers. You can use the '''OpenSchema''' method to determine what tables are contained in a Database Container (DBC), as demonstrated in the example in the | The ActiveX Data Objects (ADO) Connection object's '''OpenSchema''' method allows programmatic access to metadata about various database containers. You can use the '''OpenSchema''' method to determine what tables are contained in a Database Container (DBC), as demonstrated in the example in the "More Information" section. | ||
</div> | </div> | ||
Line 66: | Line 66: | ||
#DEFINE adSchemaTables 20 | #DEFINE adSchemaTables 20 | ||
cn = CREATEOBJECT( | cn = CREATEOBJECT("ADODB.Connection") | ||
rsTable = CREATEOBJECT( | rsTable = CREATEOBJECT("ADODB.Recordset") | ||
* connection string for TESTDATA | * connection string for TESTDATA | ||
* in the current drive and directory - change this | * in the current drive and directory - change this | ||
* as appropriate for your application | * as appropriate for your application | ||
lcConnStr = | lcConnStr = "Provider=MSDASQL.1;" + ; | ||
"Extended Properties=DSN=Visual FoxPro Database;" + ; | |||
"SourceDB=testdata.dbc;" + ; | |||
"SourceType=DBC;" + ; | |||
"Exclusive=No;" + ; | |||
"BackgroundFetch=Yes;" + ; | |||
"Collate=Machine;" | |||
WITH cn | WITH cn | ||
Line 85: | Line 85: | ||
rsTable = .OpenSchema(adSchemaTables) | rsTable = .OpenSchema(adSchemaTables) | ||
DO WHILE NOT rsTable.EOF | DO WHILE NOT rsTable.EOF | ||
? rsTable.FIELDS( | ? rsTable.FIELDS("TABLE_NAME").VALUE | ||
rsTable.MoveNext | rsTable.MoveNext | ||
ENDDO | ENDDO |
Latest revision as of 13:52, 21 July 2020
Article ID: 249718
Article Last Modified on 7/13/2004
APPLIES TO
- Microsoft ActiveX Data Objects 2.5
- Microsoft Visual FoxPro 5.0 Standard Edition
- Microsoft Visual FoxPro 5.0a
- Microsoft Visual FoxPro 6.0 Professional Edition
This article was previously published under Q249718
SUMMARY
The ActiveX Data Objects (ADO) Connection object's OpenSchema method allows programmatic access to metadata about various database containers. You can use the OpenSchema method to determine what tables are contained in a Database Container (DBC), as demonstrated in the example in the "More Information" section.
MORE INFORMATION
To use this example, save and then run the following program. Make sure that you modify the connection string to point to the DBC of your choice.
* OpenSchema.prg * Demonstrates the use of the ADO Connection * Object's OpenSchema method to examine tables * in a container. Depending on the provider, * it can also be used to examine columns, * indices, stored procedures, etc. #DEFINE adSchemaTables 20 cn = CREATEOBJECT("ADODB.Connection") rsTable = CREATEOBJECT("ADODB.Recordset") * connection string for TESTDATA * in the current drive and directory - change this * as appropriate for your application lcConnStr = "Provider=MSDASQL.1;" + ; "Extended Properties=DSN=Visual FoxPro Database;" + ; "SourceDB=testdata.dbc;" + ; "SourceType=DBC;" + ; "Exclusive=No;" + ; "BackgroundFetch=Yes;" + ; "Collate=Machine;" WITH cn .ConnectionString = lcConnStr .OPEN rsTable = .OpenSchema(adSchemaTables) DO WHILE NOT rsTable.EOF ? rsTable.FIELDS("TABLE_NAME").VALUE rsTable.MoveNext ENDDO ENDWITH
After you run the program, the tables in the specified DBC should be listed on the Visual FoxPro desktop.
Additional query words: ADO OpenSchema adSchemaTables schema container
Keywords: kbhowto kbcodesnippet kbdatabase KB249718