ms-accessdelphic++builderadodbtadotable

Is there any way to tell if the TADOTable I am looking for is in the database (MS Access)?


I use C++ Builder (Delphi 10.2 and C++Builder 10.2 Update 2) and I need a method that, in case there is no particular table, creates it using TADO objects (ADODB)? I mean TADOQuery, TADOTable, TADOConnection, etc.

How can I do this?

I tried looking at the methods of TADOConncection, of TADOTable, but none of them seem to be useful. I also tried this route (https://docwiki.embarcadero.com/Libraries/Alexandria/en/Bde.DBTables.TTable.Exists) but there are compatibility problems.


Solution

  • Does this help ?

    TADOConnection *YOUR_TADOCONNECTION; // your connection defined earlier in your code
    
    
    TStringList *TableList = new TStringList;
    bool WithSystemTables = true; // or false according to your requirements
    YOUR_TADOCONNECTION->GetTableNames(TableList, WithSystemTables);
    for (int i = 0 i < TableList->Count(); i++) {
       String NextTableName = TableList->Strings[i];
       /*.... your check for the table name being the one you want goes here .... */
    }
    delete TableList;