Home | SQLAPI++ (original) (raw)

SQLAPI++

C++ library for interfacing with

multiple SQL databases


Connect to Database

Just make a call to SAConnection::Connect and provide the credentials. SQLAPI++ does the rest by dynamically loading specified client's native library and calling corresponding APIs.

SAConnection con;
con.Connect(_TSA("demo"), _TSA("guest"), _TSA("secret"), SA_SQLServer_Client);

Insert Data into a Table

To insert data create SACommand, bind input variables as needed using stream operators and call SACommand::Execute to send command to the server. SQLAPI++ takes care of preparing and executing the command using native APIs when needed.

SACommand insert(&con, _TSA("INSERT INTO EMPLOYEES (NAME, AGE) VALUES (:1, :2)"));

insert << _TSA("Tom Patt") << 30;
insert.Execute();
insert << _TSA("Nick Barry") << 35;
insert.Execute();

Read Data from a Table

To read data execute a SELECT command, bind WHERE clause variables as needed and use SACommand::FetchNext in a loop to retrieve all the rows. SQLAPI++ does the hard work of interfacing with native APIs, allocating buffers, etc.

SACommand select(&con, _TSA("SELECT NAME, AGE FROM EMPLOYEES WHERE AGE > :1"));

select << 30;
select.Execute();

while(select.FetchNext()) {
    SAString sName = select[1].asString();
    long nAge = select[2].asLong();
    printf("Name: %s, age: %d \n", sName, nAge);
}

More Examples

Example 1. Connecting to database (and error handling)
Example 2. Executing a simple SQL command
Example 3. Binding input parameters
Example 4. Executing a select query (and fetching result set)
Example 5. Binding LongBinary, LongChar, BLob and CLob data
Example 6. Fetching LongBinary, LongChar, BLob and CLob data
Example 7. Multi-threading support and canceling queries
Example 8. Fetching records in bulk
Example 9. Using Oracle REF CURSORs
Example 10. Using Oracle nested cursors

Compatibility

SQLAPI++ library supports the following C/C++ compilers:

Latest Release

General MariaDB MySQL OLEDB SQLServer(ODBC)

New Features
Bug Fixes

See full history...