| Home | How To | Online Documentation | Support | Download | Order |
|
|
Connecting to databasesTo 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: con.Disconnect(); 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. Problems and QuestionsIf you haven't found the answer to your questions or have some problems on using the Library, please, send e-mail to howto@sqlapi.com.
|
|