Also not a great task. Goto the row you wish to delete and call hk_datasource::delete_actualrow()
Example 7-1. Delete a row
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("mysql");
8 if (myconnection==NULL) {cout <<"error creating myconnection"<<endl;exit(1);}
9 myconnection->set_host("localhost");
10 myconnection->set_user("root");
11 myconnection->set_password("mypasswd");
12 myconnection->connect();
13
14 hk_database* mydatabase=myconnection->new_database("exampledb");
15 if (mydatabase==NULL) {cout <<"error creating mydatabase"<<endl;exit(1);}
16 hk_datasource* mydatasource= mydatabase->new_table("authors");
17 if (mydatasource==NULL) {cout <<"error creating mydatasource"<<endl;exit(1);}
18 mydatasource->enable();
19
20 hk_column* mycolumn = mydatasource->column_by_name("name");
21 if (mycolumn==NULL) {cout <<"error getting column"<<endl;exit(1);}
22
23 mydatasource->goto_row(3);
24 mydatasource->delete_actualrow();
25
26
27 delete mydrivermanager;
28 } |
When you try this out you will be asked if you really want to delete the data. If this question is disturbing you switch it off. Use the function hk_class::set_showpedantic(false); for this.