C++操作MySQL,有用的朋友顶下,辛苦的原创啊. - 天下 - C++博客

news/2025/4/22 0:54:41

C++操作MySQL,有用的朋友顶下,辛苦的原创啊. - 天下 - C++博客

C++操作MySQL,有用的朋友顶下,辛苦的原创啊.
向google大神搜 :
mysql-connector

http://www.mysql.com/products/connector/

这些就是mysql所谓的连接器吧.
一路向下看到:
C++ Wrapper for MySQL C API (MySQL++) Download
http://gna.org/projects/mysqlpp/
下载手册慢慢慢慢看吧你.

1. 先到http://tangentsoft.net/mysql++/ 下载mysql++源码.
2. 将mysql++的VS2008的PRO打开后编译成msyqlpp.lib,mysqlpp.dll等几个动态或静态库。
需要注意的是mysql的头文件及相关库文件需指定地方或加到VS工具的option->vc directories中.
3.请把相应的DEBUG及RELEASE版本的DLL及LIB放到相应的目录.否则调试报异常.
#include <afxwin.h>
#include 
<iostream>
#include 
"lib/mysql++.h"
using namespace std;
int main(){
    
char name[50];
    mysqlpp::Connection conn(
false);
    
if (conn.connect("test","192.168.0.175","root","aaaaaa") ) {
        mysqlpp::Query SetCharacterSetQuery 
= conn.query("SET names 'utf8'");
        SetCharacterSetQuery.exec(); 
//注意这里还要SetCharacterSetQuery.exec() ,和C语言的API不同.
        mysqlpp::Query query = conn.query("select * from doc_threads");
        mysqlpp::StoreQueryResult res 
= query.store();
        
if (res) {
            cout 
<< res[0]["id"<< ' ' << CW2A(CA2W(res[0]["name"],CP_UTF8),CP_ACP) << ' ' <<endl;
            cout 
<< res[1]["id"<< ' ' << CW2A(CA2W(res[1]["name"],CP_UTF8),CP_ACP) << ' ' <<endl;
        }
    }
    conn.disconnect();
    
return 0;
}

https://dhexx.cn/news/show-2654226.html

相关文章

sklearn学习——递归特征消除法(RFE)

sklearn学习——递归特征消除法&#xff08;RFE&#xff09; 1 作用 消除特征之间的冗余&#xff0c;选取最优特征组合。降低特征维数。 2 步骤 将筛选的k个特征作为初始特征子集输入到随机森林分类器中&#xff0c;计算得到每个特征的重要性&#xff0c;并利用交叉验证方法…

Java Code Review清单

2019独角兽企业重金招聘Python工程师标准>>> 整洁的代码 清单项目分类使用可以表达实际意图(Intention-Revealing)的名称有意义的名称每一个概念只用一个词有意义的名称使用方案/问题领域名称有意义的名称类应该是比较小的!类函数应该是比较小的!函数只做一件事函数…

LeetCode Generate Parentheses

题目&#xff1a; Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For example, given n 3, a solution set is: "((()))", "(()())", "(())()", "()(())", "()()(…

python起步——可变对象和不可变对象

学习python了一小段时间&#xff0c;觉得整体上还是真的让程序更好写了。   学习过程中&#xff0c;突然想到一个问题——我之前博客写过的一篇文章&#xff0c;关于不用第三个数交换a、b的问题&#xff1a;http://www.cnblogs.com/FreeAquar/archive/2012/07/22/2603381.htm…

Java学习笔记(1)——常用cmd命令与Java编制编译

Java学习笔记——常用cmd命令与Java编制编译 1 JDK下载安装与环境配置 附上链接 2 常用cmd命令 dir 列出当前目录下的文件以及文件夹md 创建目录rd 删除目录cd 进入指定目录cd… 退回到上一级目录del 删除文件 3 Java特点 简单性面向对象分布式健壮性安全性体系结构中立…

华为防火墙-适合CSSIP方向

新版的OS初始console的用户名&#xff1a;admin&#xff0c;密码&#xff1a;Admin123连接console进入设备&#xff1a; Copyright(C) 2010-2013 Huawei Technologies Co., Ltd. *All rights reserved *Without the owners prior written consent, *no decompiling or reverse-…

LeetCode Letter Combinations of a Phone Number

题目&#xff1a; Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telephone buttons) is given below. Input:Digit string "23" Output: ["ad", &q…

Java学习笔记(2)——基础语法

Java学习——基础语法 1 第一个Java程序 public class 后面采用的类名和文件名保持一样&#xff0c;一个Java程序里面只有一个public class&#xff1b;class后面类名必须以字母开头&#xff0c;后面可以跟字母和数字的任意组合&#xff1b;System.out.println&#xff08;&a…

LeetCode Clone Graph

题目&#xff1a; Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors. OJs undirected graph serialization: Nodes are labeled uniquely. We use # as a separator for each node, and , as a separator for node label and …

彩票问题,长度为6的int型数组,要求取值为1-30,同时元素值各不相同

题目 创建一个长度为6的int型数组&#xff0c;要求取值为1-30&#xff0c;同时元素值各不相同 解法 class CaiPiaoNumber {public static void main(String[] args) {int[] arr new int[6]; // 创建数组for (int i 0; i <arr.length ; i) { …