To connect to a database you should create a connection object and then connect it.

For example, let's connect to SQL Server database Demo as user Guest with a password May and then disconnect from it.

Step 1. Creating a connection object.

A connection object is represented by SAConnection class.

SAConnection con;

The line above creates a connection object con.

If you want to define the connection con as a connection to SQL Server database before calling SAConnection::Connect method use SAConnection::setClient method:

con.setClient( SA_SQLServer_Client );

Step 2. Connecting to a database.

After the connection is created we need to connect it using SAConnection::Connect method.

con.Connect( "Demo", "Guest", "May", SA_SQLServer_Client );

If you have used SAConnection::setClient method earlier you can call SAConnection::Connect method with skipping the last parameter:

con.Connect( "Demo", "Guest", "May" );

Step 3. Disconnecting from a database.

You can disconnect your connection object at any time with a call to the SAConnection::Disconnect method:


It is safe to skip calling SAConnection::Disconnect method explicitly. Destructor SAConnection::~SAConnection will correctly close the connection if you didn't call SAConnection::Disconnect method before.

If you haven't found the answer to your questions or have some problems using the Library, please, send an e-mail to

Last modified: 19 October 2019