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

[C++]MySQL数据库操作实例

环境设置:
安装完MySQL之后,将安装目录中的include目录下的libmysql.lib文件拷到VS2008安装目录中的VC\lib\下,然后在 项目-选项-c/c++-常规 中的附加包含目录以及 链接器-常规 中的附加库目录中加入“c:\MySQL\include\”,并且在 链接器-输入 中的附加依赖项内添加“libmysql.lib”,这样即可使编译器找到mysql.h头文件,并可在程序中使用c语言的mysql API来操作数据库。(如果MySQL安装目录中无include目录,可到MySQL官网下载并安装MySQL connector for C,并修改include目录路径)
代码示例: 
#include <Windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <mysql.h> 
#include <iostream>
using namespace std;
int main()
{
    const char user[] = "root";         //username
    const char pswd[] = "root";         //password
    const char host[] = "localhost";    //or"127.0.0.1"
    const char table[] = "test";        //database
    unsigned int port = 3306;           //server port        
    MYSQL myCont;
    MYSQL_RES *result;
    MYSQL_ROW sql_row;
    MYSQL_FIELD *fd;
    char column[32][32];
    int res;
    mysql_init(&myCont);
    if(mysql_real_connect(&myCont,host,user,pswd,table,port,NULL,0))
    {
        cout<


相关文档:

windows的64位平台rails连接mysql的方法


安装mysql
gem install mysql
使用mysql,如,rake db:migrate
会报错:
E:\study\ruby\rails_space>rake db:migrate
(in E:/study/ruby/rails_space)
!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.
rake aborted!
193: ......

MySQL connection strings

MySQL ODBC connection strings
Open connection to local MySQL database using MySQL ODBC 3.51 Driver
"Provider=MSDASQL; DRIVER={MySQL ODBC 3.51Driver}; SERVER= localhost; DATABASE=Your_MySQL_Database; UID= Your_Username; PASSWORD=Your_Password; OPTION=3"
MySQL OLE DB & OleDbConnection (.NET fr ......

MySQL存储过程学习


http://www.mysql.cn/
事务,参数,嵌套调用,游标,循环, 触发器,视图,约束, 索引,。。。
1. 创建实例数据库
   create database db5;
   use db5;
2.创建一个简单的工作表,并插入数据
   create table t(s1 int);
   insert into t values(5);
3.创建程序实例 crea ......

mysql 存储过程 游标的例子

create procedure getInfor2()
BEGIN
declare _abc varchar(200);
declare stopFlag int;
DECLARE cursor_name CURSOR
FOR
select zhuanyuan from server;
DECLARE CONTINUE HANDLER FOR NOT FOUND set stopFlag=1;
OPEN cursor_name;
REPEAT
FETCH cursor_name INTO _abc;
begin
if _abc='root'
the ......

MySQL中select * for update锁表的问题


select * for update锁表的问题
由于InnoDB预设是Row-Level Lock,所以只有「明确」的指定主键,MySQL才会执行Row lock (只锁住被选取的资料例) ,否则MySQL将会执行Table Lock (将整个资料表单给锁住)。
举个例子:
假设有个表单products ,里面有id跟name二个栏位,id是主键。
例1: (明确指定主键,并且有此笔资料, ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号