#include <WinSock.h>
#include <windows.h>
#include <mysql.h>
#include <string>
#include <iostream>
using namespace std;
int main()
{
const char user[] = "root";
const char pswd[] = "891017";
const char host[] = "localhost";
const char table[] = "";
unsigned int port = 3306;
MYSQL myCont;
MYSQL_RES *result = NULL;
MYSQL_ROW sql_row;
int res, res2;
mysql_init(&myCont);
if (mysql_real_connect(&myCont, host, user, pswd,
table, port, NULL, CLIENT_MULTI_STATEMENTS | CLIENT_MULTI_RESULTS))
{
res = mysql_query(&myCont, "use test; select * from test1;");//查询
if (!res)
{
if ((res2 = mysql_more_results(&myCont)) <= 0)
{
//...
}
else
{
printf("[%d]%s", res2, mysql_error(&myCont));
}
}
else
{
cout << "query sql failed!" << endl;
printf("[%d]%s", res, mysql_error(&myCont));
}
}
else
{
cout << "connect failed!" << endl;
}
if (result != NULL)
mysql_free_result(result);
mysql_close(&myCont);
system("pause");
return 0;
}
/*
执行结果:
[1]请按任意键继续. . .
*/
解决方案:10分
你是想要一次执行多个sql,然后接下来读取多个结果集吗
解决方案:10分
不太明白什么意思