Example 1.1. Get in contact with your SQL Server
#define HAVE_SSTREAM 1 #include <hk_classes.h> #include <iostream> int main() { hk_drivermanager* mydrivermanager = new hk_drivermanager(); if (mydrivermanager==NULL) {cout <<"error creating mydrivermanager"<<endl;exit(1);} hk_connection* myconnection = mydrivermanager->new_connection(); if (myconnection==NULL) {cout <<"error creating myconnection"<<endl;exit(1);} myconnection->connect(); delete mydrivermanager; }
This is the shortest hk_classes program. First create a object instance of hk_drivermanager(). It handles the databasedriver management.
To connect to a SQL server you need a instance of hk_connection. By creating it, the wished database driver will be selected. When you connect with the "connect()"-command the password and some other information will be asked.
Nothing really visible happens here.To get in contact with your data just see the next chapters.