Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ADO/ADOX and Access tables
Message
From
29/04/2002 04:08:24
 
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00650178
Message ID:
00650264
Views:
23
This message has been marked as the solution to the initial question of the thread.
Einar,
Here are two different approaches you could use. The first one uses ADO and OpenSchema(). The second uses SPT and SQLTABLES().
*-- using ADO
#DEFINE adSchemaTables 20
oConnection = CreateObject("adodb.connection")
oConnection.Open("DRIVER={Microsoft Access Driver (*.mdb)};" +;
                 "Dbq=d:\vfpApps\northwind.mdb;" +;
                 "Uid=Admin;" +;
                 "Pwd=;")
oRS = oconnection.OpenSchema(adSchemaTables )
oRs.Find("table_name = 'customers'")
llFound = IIF(oRS.EOF, .f., .t.)
*-- using SPT

*-- build connection string
lcConnectionStr = "DRIVER={Microsoft Access Driver (*.mdb)};" +;
                  "Dbq=d:\vfpApps\northwind.mdb;" +;
                  "Uid=Admin;" +;
                  "Pwd=;"
*-- connect to MDB
lnSql = SQLSTRINGCONNECT(lcConnectionStr)
*-- get tables of MDB into cursor
SQLTABLES(lnSql, "TABLE")
*-- check if table exists
LOCATE FOR UPPER(table_name)="CUSTOMERS"
IF FOUND()
  *-- table exists
ELSE
  *-- table doesn't exist
ENDIF
>What is the best way to test for existence of a table in a Access database?
Daniel
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform