这是我写给lccwin32的
http://www.csdn.net/develop/read_article.asp?id=16916代码删除第一行就可以用了,挂上头文件和lib就可以了说。#include <stdio.h>
#include "mysql.h"MYSQL *myData;int main(int argc, char *argv[])
{
char userid[20];
strcpy(userid, "root"); // 账号
char password[20];
strcpy(password, ""); // 密码
char host[20];
strcpy(host, "localhost"); // 主机
char dbName[10];strcpy(dbName, "test"); // 数据库
if ( (myData = mysql_init((MYSQL*) 0)) &&
mysql_real_connect(myData, host, userid, password, dbName, MYSQL_PORT, NULL, 0))
printf("Mysql ready\n");
else
exit(0);
mysql_close( myData ) ;
return 1;
}
http://www.csdn.net/develop/read_article.asp?id=16916代码删除第一行就可以用了,挂上头文件和lib就可以了说。#include <stdio.h>
#include "mysql.h"MYSQL *myData;int main(int argc, char *argv[])
{
char userid[20];
strcpy(userid, "root"); // 账号
char password[20];
strcpy(password, ""); // 密码
char host[20];
strcpy(host, "localhost"); // 主机
char dbName[10];strcpy(dbName, "test"); // 数据库
if ( (myData = mysql_init((MYSQL*) 0)) &&
mysql_real_connect(myData, host, userid, password, dbName, MYSQL_PORT, NULL, 0))
printf("Mysql ready\n");
else
exit(0);
mysql_close( myData ) ;
return 1;
}
有机会大家讨论讨论
Wedit output window 构建: Sat Feb 23 17:32:00 2002
test.obj .text: undefined reference to '_mysql_close@4'
test.obj .text: undefined reference to '_mysql_real_connect@32'
test.obj .text: undefined reference to '_mysql_init@4'
编译和连接 耗时:0.2秒 返回代码:3
#pragma lib "libmysql.lib"
我使用vc6.0做编译器!
已经成功连接mysql!
谢谢swotcoder(苦丁)的帮助!