ODBC access

  1. Download IBEBlockScriptSamples.zip from https://www.ibexpert.com/download/other_files/
  2. Copy Demo.mdb and ODBCAcc.ibeblock (found in the Blocks/ODBC Access directory) into a separate directory
  3. Copy ODBCAcc.ibeblock (copy of script below) into the SQL Editor.
  4. You can find the correct connection string for the ODBC driver you are using here: https://www.connectionstrings.com/
  5. Modify the path to Demo.mdb.
  6. Press [F9] to execute the block.
 execute ibeblock 
 returns (CustNo integer, Company varchar(100), Addr1 varchar(100)) 
    as
    begin
    InCust = 3000;
    OdbcCon = ibec_CreateConnection(__ctODBC, 'DBQ=D:\Delphi5\CMP\mODBC\DB\demo.mdb;DRIVER=Microsoft Access Driver (*.mdb)');
    ibec_UseConnection(OdbcCon);

    execute statement 'select Company from customer where CustNo = 4312' into :MyCust;

    for select CustNo, Company, Addr1 from customer
       where CustNo > :InCust
       order by company
       into :CustNo, :Company, :Addr1
    do
    begin
       suspend;
    end
    ibec_CloseConnection(OdbcCon);
 end

back to top of page

https://www.connectionstrings.com offers a huge range of ODBC drivers for all possible databases:

along with the connection strings. For example, if you want to access Excel data:

Please also refer to IBExpert's ODBC Viewer.

See also:
IBEBlock example: ODBC Access
ODBC Viewer

back to top of page
<< Automatic script execution | IBEBlock | Extract metadata using IBEBlock >>