易截截图软件、单文件、免安装、纯绿色、仅160KB

实例讲解如何使用C++操作MySQL数据库类

 
  用C++操作MySQL数据库类:
  注释:这几个类对处理不是很大数据量的操作是很理想的, 但不适宜特大型的数据的查询,因为源码中将查询到的数据直接放入了内存。
  /*
  * project:
  * 通用模块 ( 用 c++ 处理 mysql 数据库类,像ADO )
  *
  * description:
  *
  * 通过DataBase,RecordSet,Record,Field类,实现对mysql数据库的操作
  * 包括连接、修改、添加、删除、查询等等,像ADO一样操作数据库,使
  * 用方便
  *
  * ( the end of this file have one sample,
  * welcom to use... )
  *
  *
  * file:zlb_mysql.h
  *
  * author: @ zlb
  *
  * time:2005-12-12
  *
  *
  *
  --*/
  #ifndef ZLB_MYSQL_H
  #define ZLB_MYSQL_H
  #include "mysql.h"
  #include
  #include
  #include
  using namespace std;
  namespace zlb_mysql{
  /*
  * 字段操作
  */
  class Field
  {
  public :
  /* 字段名称 */
  vector m_name;
  /* 字段类型 */
  vector m_type;
  public :
  Field();
  ~Field();
  /* 是否是数字 */
  bool IsNum(int num);
  /* 是否是数字 */
  bool IsNum(string num);
  /* 是否是日期 */
  bool IsDate(int num);
  /* 是否是日期 */
  bool IsDate(string num);
  /* 是否是字符 */
  bool IsChar(int num);
  /* 是否是字符 */
  bool IsChar(string num);
  /* 是否为二进制数据 */
  bool IsBlob(int num);
  /* 是否为二进制数据 */
  bool IsBlob(string num);
  /* 得到指定字段的序号 */
  int GetField_NO(string field_name);
  };
  /*
  * 1 单条记录
  * 2 [int ]操作 [""]操作
  */
  class Record
  {
  public:
  /* 结果集 */
  vector m_rs;
  /* 字段信息 占用4字节的内存 当记录数很大是回产生性能问题 */
  Field *m_field;
  public :
  Record(){};
  Record(Field* m_f);
  ~Record();
  void SetData(string value);
  /* [""]操作 */
  string operator[](string s);
  string operator[](int num);
  /* null值判断 */
  bool IsNull(int num);
  bool IsNull(string s);
  /* 用 value


相关文档:

MYSQL 字符集问题

 
 
 
MySQL的字符集支持(Character Set Support)有两个方面:
     字符集(Character set)和排序方式(Collation)。
对于字符集的支持细化到四个层次:
     服务器(server),数据库(database),数据表(table)和连接(connection)。
1.MySQL默认字符集
  ......

c与c++的区别(基础)

为了用vc写一个最简单的 socket 程序,花费了一个下午的时间,过程中出现的错误有:
'SOCKET' : illegal use of this type as an expression
syntax error : missing ';' before 'type'
syntax error : identifier 'InitWinsock'   -->       bool   InitWinsock( ......

MySQL学习随笔1

查看数据库版本  select version(), current_date();
显示数据库用 show databases;
选择某个数据库用use db_1;
创建数据库用create db_1;
插入数据用insert into db_1 values(...);
显示当前选择的数据库用select database();
创建表用create table tb_1 (...);
显示所有表用show tables;
显示某个表的所有内 ......

php程序插数据入mysql, 插入失败问题

注意:引用"肥占的博客 http://fatjames.extjs.org.cn/archives/40"
mysql5.x sql-mode 引起的错误
今天安装了个mysql5.0,拿了一个很久之前网上下的程序检查一下是否工作正常.
发现以前的程序居然不能正常运行,提示信息如下:
Database error: Invalid SQL: INSERT INTO
Survey_UserHistory(userId,jobId,type ......

mysql 取出当前记录的上一条记录和下一条记录

已知当前记录id为$id,取出当前记录的上一条记录和下一条记录的id,title字段。表名news。
$sql = "SELECT CASE WHEN SIGN(id - $id) > 0 THEN MIN(id) WHEN SIGN(id - $id) < 0 THEN MAX(id) END AS id,title from news WHERE id <> $id GROUP BY SIGN(id - $id) ORDER BY SIGN(id - $id)"; ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号