主题:[讨论]C++在mysql中查询问题
求哪位可以帮帮看一下,这段程序那里有错误,我试过结果是无法查询数据库里的数据,但是可以显示s1.
目的是要把s1里的每个字符都在数据库中调用出。
谢谢!
char s1[1024];
cout << "Enter a sentence: ";
cin.get (s1,1024);
cout << endl;
char* pch;
cout<<"Split tokens.."<<endl;
pch=strtok(s1," ");
while(pch!=NULL)
{
cout<<pch<<" ";
pch=strtok(NULL," ");
res=stmt->executeQuery("select * from test5 where SU='"& pch &"'");
while(res->next ())
{
cout<<"Result: "<<res->getString(2)<<endl;
}
}
目的是要把s1里的每个字符都在数据库中调用出。
谢谢!
char s1[1024];
cout << "Enter a sentence: ";
cin.get (s1,1024);
cout << endl;
char* pch;
cout<<"Split tokens.."<<endl;
pch=strtok(s1," ");
while(pch!=NULL)
{
cout<<pch<<" ";
pch=strtok(NULL," ");
res=stmt->executeQuery("select * from test5 where SU='"& pch &"'");
while(res->next ())
{
cout<<"Result: "<<res->getString(2)<<endl;
}
}