Hi, I am trying to let a string(a sentance) to be red into mysql.but I only can do it within one word, how can I do more?
this is my code:
//----------------------------------
sql::Driver *driver;
sql::Connection *con;
sql::Statement *stmt;
sql::ResultSet *res;
driver = get_driver_instance();
con = driver->connect("localhost", "root", "qwerty");
con->setSchema("menagerie");
stmt = con->createStatement();
stmt->execute("set names \'GBK\'");
cout << "Please enter: ";
getline(cin,str1);
string::iterator It = str1.begin();
while ( It != str1.end() )
{
if (*It == ' ' )
*It = ' ';
cout <<*It++;
}//========================will stop here no going down anymore.any ideas why.
res=stmt->executeQuery("select * from test2 where english='"+str1+"'");
while (res->next())
{
cout<<"Result: "<<res->getString(2);
}
delete res;
delete stmt;
delete con;