![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I am having troubles getting my output to work with printf. gmod.cc:cannot pass objects of non-POD type `const class This is part of the code I am playing with Connection con(use_exceptions); con.connect("netjuke", "127.0.0.1", "******", "******"); Query query = con.query(); query << "SELECT location FROM netjuke_tracks Where al_id=17 AND track_number=1"; Result res = query.store(); Row row; Result::iterator i; for(i=res.begin();i!=res.end();i++) { row = *i; printf("%s", row[0]); |
|
} I change it from for(i=res.begin();i!=res.end();i++) { row = *i; cout << row[0]; |
#3
| |||
| |||
|
|
On Wed, Apr 06, 2005 at 12:19:58AM -0700, timothy johnson wrote: I am having troubles getting my output to work with printf. gmod.cc:cannot pass objects of non-POD type `const class This is part of the code I am playing with Connection con(use_exceptions); con.connect("netjuke", "127.0.0.1", "******", "******"); Query query = con.query(); query << "SELECT location FROM netjuke_tracks Where al_id=17 AND track_number=1"; Result res = query.store(); Row row; Result::iterator i; for(i=res.begin();i!=res.end();i++) { row = *i; printf("%s", row[0]); row[0] can be converted to a number of types, so try casting to the type you want: static_cast<const char *> (row[0]) } I change it from for(i=res.begin();i!=res.end();i++) { row = *i; cout << row[0]; This uses overloaded operator<<(), so no cast is needed, and hence works. - Chris -- MySQL++ Mailing List For list archives: http://lists.mysql.com/plusplus To unsubscribe: http://lists.mysql.com/plusplus?unsu...mail (DOT) com |
#4
| |||
| |||
|
|
What about using vars in the query line? query << "SELECT * FROM table WHERE id=" . var; this way didnt work sprintf(query. "SELECT * FROM table WHERE id=%i". var); nor did this way work. |
#5
| |||
| |||
|
|
Going from memory, I think you use the quote manipulator like this, but I could be wrong, I don't use it regularly: query << "SELECT * FROM table WHERE id=" << quote << var; |
![]() |
| Thread Tools | |
| Display Modes | |
| |