List,
Thanks so much for your responses to my "Just a little help: post.
I feel I need to clarify my question a bit plus I had more time to test =
different configurations.
Here's a sample program.
---------------CODE---------------------------
----headers----
main ()=20
{
int val =3D 0;
mycppapi::Connection con;
con.set_Host("localhost");
con.set_User("root");
con.set_Password("1234");
con.set_Port(3306);
con.connect();
/* connects just fine */
con.select_database("mydb");
/* selects the database fine here */
while(1) {
val =3D grab_a value(); /* some function that grabs some =
value */
InsertIntoDB(con,val); /* insert new val into db */
/* I assume all destructors free/clear all the variables before =
I go around again.?? */
}
} /* end main() */
int InsertIntoDB( mysqlcppapi::Connection& con, int value)
{
try {
mysqlcppapi::Query query =3D con.create_Query();
query << "insert into MYTABLE (myvalue) values( " << val << ")" << =
std::ends;
/* Tried this query << "insert into MYTABLE (va) values( " << val << =
")" << ends; */
/* Tried this query << "insert into MYTABLE (va) values( " << val << =
")" << endl; */
/* Tried this query << "insert into MYTABLE (va) values(100)"; */ =20
/* Tried std:osstringstream */
=20
query.execute();
return(0);
} catch (mysqlcppapi::ex_BadQuery &er)
{
do_stuff();
}
catch (mysqlcppapi::ex_BadConversion &er)
{
do_stuff();
}
} /* end InsertIntoDB() */
-----------CODE--------------------
-----Enviornment-------
I am using gcc 2.96
DB API RESULT =
MESSAGE
-------------------------------------------------------------------------=
-----------------------------------
4.0.3 1.91 exception ex_BadQuery caught Query was =
Empty
3.23.53a 1.91 exception ex_BadQuery caught Query was =
Empty
4.0.3 1.90 works fine
3.23.53a 1.90 works fine
4.0.3 1.7.5 works fine
3.23.53a 1.7.5 works fine
Here's my conclusion.
1.7.5 Query is std::strstring requires std:ends to terminate query. =
works fine
1.9.0 Query is std::strstring requires std:ends to terminate query. =
works fine
1.9.1 Query is std::stringstream. I havn't been able to get any =
combination to work.
??? Were query templates add to this branch yet??? I havn't found any =
examples yet :- )
Anyway, thanks again for the responses.
Sorry if this was too long..
Keith
|