|
这是我在网上随便下的一段demo
#include <windows.h>
#include <process.h>
#include <iostream>
#include <string>
#include "mysql.h" //安装的mysql的头文件所在的位置
using namespace std;
string host="localhost";
string user="root";
string pwd="";
string dbname="pure";
string sql="select * from cdn";
unsigned int port=3306;
int status;
int main(){
MYSQL *mysql;
mysql=mysql_init(0);
MYSQL_RES *result;
MYSQL_ROW row;
if(mysql_real_connect(mysql,host.c_str(),user.c_str(),pwd.c_str(),dbname.c_str(),port,NULL,CLIENT_FOUND_ROWS)==NULL){
cout << "connect failure!" << endl;
return EXIT_FAILURE;
}else{
cout << "connect success!" << endl;
}
mysql_set_character_set(mysql,"gbk");
status=mysql_query(mysql,sql.c_str());
if(status !=0 ){
cout << "query failure!" << endl;
}
cout << "the status is :" << status << endl;
result=mysql_store_result(mysql);
while(row=mysql_fetch_row(result)){
cout << row[1] <<"|"<< row[2] << endl;
}
mysql_free_result(result);
mysql_close(mysql);
}
我安装的是mysql-essential-5.1.33-win32
开发环境是VS2008
库文件什么的都配置好了
编译通过
运行的时候就出现错误:无法定位程序输入点mysql_set_character_set于动态连接库LIBMYSQL.dll上
请大家帮帮忙
我是要准备做一个对MYSQL的C API的封装类,想先测试下,可是上述问题解决不了,测试不了........
PS:我是新手 |
|