Example 1-1. Get in contact with your SQL Server
1 #include <hk_classes.h>
2 #include <iostream>
3 int main()
4 {
5 hk_drivermanager* mydrivermanager = new hk_drivermanager();
6 if (mydrivermanager==NULL) {cout <<"error creating mydrivermanager"<<endl;exit(1);}
7 hk_connection* myconnection = mydrivermanager->new_connection();
8 if (myconnection==NULL) {cout <<"error creating myconnection"<<endl;exit(1);}
9 myconnection->connect();
10 delete mydrivermanager;
11 } |
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.