免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1678 | 回复: 2
打印 上一主题 下一主题

[C++] C++访问mysql的问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-03-02 11:36 |只看该作者 |倒序浏览
#include "util.h"
#include <mysql++.h>
#include <iostream>
#include <iomanip>
using namespace std;
int
main(int argc, char *argv[])
{
// Connect to the sample database.
mysqlpp::Connection con(false);
if (!connect_to_db(argc, argv, con)) {
return 1;
}
// Retrieve a subset of the sample stock table set up by resetdb
mysqlpp:uery query = con.query();
query << "select item from stock";
mysqlpp::Result res = query.store();
// Display the result set
cout << "We have:" << endl;
if (res) {
char buf[100];
mysqlpp::Row row;
mysqlpp::Row::size_type i;
for (i = 0; row = res.at(i); ++i) {
cout << '\t' << utf8trans(row.at(0), buf, sizeof(buf)) << endl;
}
}
else {
cerr << "Failed to get item list: " << query.error() << endl;
return 1;
}
return 0;
}
如果要访问mysql中的表是不是就将
其中红色字中mysql++.h换成mysql.h行了?

谢谢!!!

论坛徽章:
1
2015年迎新春徽章
日期:2015-03-04 09:56:11
2 [报告]
发表于 2006-03-02 14:39 |只看该作者
view the mysql manual

论坛徽章:
0
3 [报告]
发表于 2006-03-02 18:00 |只看该作者
没看懂

为什么要换? 是要改成用c访问吗?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP