Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Problem with c++ mysql connectivity

This is a small program to manipulate Sql database.
We r using Linux 9.0 server . After executing the program it is showing
segmentation fault(SIGSEGV) . Plz tell me the problem with the code .


#include
#include
#include
int main()
{
Connection con("test");

Query query = con.query();

query << "insert into aaa values ('ssss',25,'s/w')";

query.execute();

query << "select * from aaa";

Result res = query.store();

cout << "Query: " << query.preview() << endl;

cout << "Records Found: " << res.size() << endl << endl;

Row row;
cout.setf(ios::left);
cout << " " << "name"
<< " " << "age"
<< endl;

Result::iterator i;
for (i = res.begin(); i != res.end(); i++) {
row = *i;
cout << " " << row[0] << " "<< row[1] << endl;

}
return 0;
}
Sign In or Register to comment.