1>------ 已启动全部重新生成: 项目: MySql-Connect, 配置: Debug Win32 ------ 1>正在删除项目“MySql-Connect”(配置“Debug|Win32”)的中间文件和输出文件 1>正在编译... 1>MySql_Connect.cpp 1>x:\编程练习\c-c++\c\mysql_connect.cpp(35) : warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. 1> d:\program files\microsoft visual studio 9.0\vc\include\stdio.h(306) : 参见“scanf”的声明 1>x:\编程练习\c-c++\c\mysql_connect.cpp(72) : warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. 1> d:\program files\microsoft visual studio 9.0\vc\include\stdio.h(366) : 参见“sprintf”的声明 1>x:\编程练习\c-c++\c\mysql_connect.cpp(86) : warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. 1> d:\program files\microsoft visual studio 9.0\vc\include\stdio.h(366) : 参见“sprintf”的声明 1>正在编译资源清单... 1>Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1 1>Copyright (C) Microsoft Corporation. All rights reserved. 1>正在链接... 1>LINK : 没有找到 d:\我的文档\Visual Studio 2008\Projects\MySql-Connect\Debug\MySql-Connect.exe 或上一个增量链接没有生成它;正在执行完全链接 1>MySql_Connect.obj : error LNK2019: 无法解析的外部符号 _mysql_close@4,该符号在函数 _main 中被引用 1>MySql_Connect.obj : error LNK2019: 无法解析的外部符号 _mysql_free_result@4,该符号在函数 _main 中被引用 1>MySql_Connect.obj : error LNK2019: 无法解析的外部符号 _mysql_num_fields@4,该符号在函数 _main 中被引用 1>MySql_Connect.obj : error LNK2019: 无法解析的外部符号 _mysql_fetch_row@4,该符号在函数 _main 中被引用 1>MySql_Connect.obj : error LNK2019: 无法解析的外部符号 _mysql_store_result@4,该符号在函数 _main 中被引用 1>MySql_Connect.obj : error LNK2019: 无法解析的外部符号 _mysql_error@4,该符号在函数 _main 中被引用 1>MySql_Connect.obj : error LNK2019: 无法解析的外部符号 _mysql_real_query@12,该符号在函数 _main 中被引用 1>MySql_Connect.obj : error LNK2019: 无法解析的外部符号 _mysql_select_db@8,该符号在函数 _main 中被引用 1>MySql_Connect.obj : error LNK2019: 无法解析的外部符号 _mysql_real_connect@32,该符号在函数 _main 中被引用 1>MySql_Connect.obj : error LNK2019: 无法解析的外部符号 _mysql_init@4,该符号在函数 _main 中被引用 1>d:\我的文档\Visual Studio 2008\Projects\MySql-Connect\Debug\MySql-Connect.exe : fatal error LNK1120: 10 个无法解析的外部命令 1>生成日志保存在“file://d:\我的文档\Visual Studio 2008\Projects\MySql-Connect\MySql-Connect\Debug\BuildLog.htm” 1>MySql-Connect - 11 个错误,3 个警告 ========== 全部重新生成: 成功 0 个,失败 1 个,跳过 0 个 ==========
#include <windows.h>
#include "stdio.h"
#include "winsock.h"
#include "mysql.h"
int main()
{
MYSQL * con; //= mysql_init((MYSQL*) 0);
MYSQL_RES *res;
MYSQL_ROW row;
char tmp[400];
//database configuartion
char dbuser[30]="root";
char dbpasswd[30]="apple";
char dbip[30]="localhost";
char dbname[50]="excel";
char tablename[50]="test";
char *query=NULL;
int x;
int y;
int rt;//return value
unsigned int t;
int count = 0;
printf("input x,y\n");
scanf("%d,%d",&x,&y);
fflush(stdin);
printf("input over\n");
con = mysql_init((MYSQL*) 0);
if ( con !=NULL && mysql_real_connect(con,dbip,dbuser,dbpasswd,dbname,3306/*TCP IP端口*/,NULL/*Unix Socket 连接类型*/,0/*运行成ODBC数据库标志*/) )
{
if (!mysql_select_db(con,dbname))
{
printf("Select successfully the database!\n");
con ->reconnect = 1;
query = "set names \'GBK\'";
//mysql_query(con,"set names \'GBK\'");
rt=mysql_real_query(con,query,strlen(query));
if (rt)
{
printf("Error making query: %s !!!\n",mysql_error(con));
}
else
{
printf("query %s succeed!\n",query);
}
}
}
else
{
MessageBoxA(NULL,"Unable to connect the database,check your configuration!","",NULL);
}
//sprintf(tmp,"update %s set 商品=\'%s\',卖出=%d,成交=%d,涨跌=%d,买进=%d,总量=%d,涨幅=%f,时间=\'%s\' where %s",tablename,goods,sold,deal,fluctuate,buy,total,delta,time,UpdateCon);
sprintf(tmp,"insert into %s values(%s,%d,%d)",tablename,"null",x,y); //注意如何向具有自增字段的数据库中插入记录
//MessageBoxA(NULL,tmp,tmp,MB_OK);
//mysql_query(con,tmp);
rt=mysql_real_query(con,tmp,strlen(tmp));
if (rt)
{
printf("Error making query: %s !!!\n",mysql_error(con));
}
else
{
printf("%s executed!!!\n",tmp);
}
sprintf(tmp,"select * from %s",tablename);
rt=mysql_real_query(con,tmp,strlen(tmp));
if (rt)
{
printf("Error making query: %s !!!\n",mysql_error(con));
}
else
{
printf("%s executed!!!\n",tmp);
}
res = mysql_store_result(con);//将结果保存在res结构体中
while(row = mysql_fetch_row(res))
{
/**
* MYSQL_ROW STDCALL mysql_fetch_row(MYSQL_RES *result);
* 检索行
*/
for(t=0;t<mysql_num_fields(res);t++)
{
printf("%s ",row[t]);
}
printf(".............\n");
count ++;
}
printf("number of rows %d\n",count);
printf("mysql_free_result...\n");
mysql_free_result(res);
mysql_close(con);
return 0;
}
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `test`
-- ----------------------------
DROP TABLE IF EXISTS `test`;
CREATE TABLE `test` (
`x` bigint(4) NOT NULL AUTO_INCREMENT,
`y` int(4) DEFAULT NULL,
`z` int(4) DEFAULT NULL,
PRIMARY KEY (`x`)
) ENGINE=InnoDB AUTO_INCREMENT=118 DEFAULT CHARSET=latin1;
-- ----------------------------
-- Records of test
-- ----------------------------
INSERT INTO `test` VALUES ('95', '12432', '4334');
INSERT INTO `test` VALUES ('96', '213', '321');
INSERT INTO `test` VALUES ('97', '213', '213');
INSERT INTO `test` VALUES ('98', '123', '231');
INSERT INTO `test` VALUES ('99', '321', '231');
INSERT INTO `test` VALUES ('100', '123', '32132');
INSERT INTO `test` VALUES ('101', '777', '32213');
INSERT INTO `test` VALUES ('102', '123', '213');
INSERT INTO `test` VALUES ('103', '21', '321');
INSERT INTO `test` VALUES ('104', '324', '432');
INSERT INTO `test` VALUES ('105', '132', '231');
INSERT INTO `test` VALUES ('106', '324', '342');
INSERT INTO `test` VALUES ('107', '23', '23');
INSERT INTO `test` VALUES ('108', '12', '21');
INSERT INTO `test` VALUES ('109', '231', '321');
INSERT INTO `test` VALUES ('110', '123', '231');
INSERT INTO `test` VALUES ('111', '123', '231');
INSERT INTO `test` VALUES ('112', '123', '123');
INSERT INTO `test` VALUES ('113', '312', '231');
INSERT INTO `test` VALUES ('114', '312', '321');
INSERT INTO `test` VALUES ('115', '23', '3');
INSERT INTO `test` VALUES ('116', '213', '312');
INSERT INTO `test` VALUES ('117', '2', '3');
-- ----------------------------
-- Table structure for `xqdata`
-- ----------------------------
DROP TABLE IF EXISTS `xqdata`;
CREATE TABLE `xqdata` (
`代码` varchar(20) NOT NULL DEFAULT '',
`商品` varchar(20) CHARACTER SET utf8 DEFAULT NULL,
`卖出` bigint(20) DEFAULT NULL,
`成交` bigint(20) DEFAULT NULL,
`涨跌` bigint(20) DEFAULT NULL,
`买进` bigint(20) DEFAULT NULL,
`总量` bigint(20) DEFAULT NULL,
`涨幅` double DEFAULT NULL,
`时间` time DEFAULT NULL,
PRIMARY KEY (`代码`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- ----------------------------
-- Records of xqdata
-- ----------------------------
INSERT INTO `xqdata` VALUES ('FITX*1', '商品', '34', '43', '23', '34', '0', '1.4', '13:23:08');
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有