C++数据库API操作mysql数据库的使用
2013-07-09 19:51
369 查看
// mysqlTest.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <MRDBIO.h>
#include <DBIO.h>
#include <iostream>
#include <string>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
CMRDBIO myDb(DBTYPE::DB_MYSQL);
// string strSQL ;
//strSQL = "insert into person values('dfsdf', 24) ";
//cout << myDb.ExecSQL(strSQL.c_str()) << endl;
/* strSQL = "insert into person values('甘全福', 24) ";
cout << myDb.ExecSQL(strSQL.c_str()) << endl;*/
/* strSQL = "delete from person where name = '甘全福'";
myDb.ExecSQL(strSQL.c_str());
*/
//strSQL = "update person set age = 88 where name = 'fsdfdfds'";
//cout << myDb.ExecSQL(strSQL.c_str()) << endl;
//strSQL = "select * from person where age = 24";
////cout << myDb.ExecSQL(strSQL.c_str()) << endl;
//CMRRECORDSET *recordSet = NULL;
//myDb.Select(strSQL.c_str(), &recordSet);
//int count = recordSet->GetRecordCount();
//cout << "查询记录总数:" << count << endl;
//for (int i = 0; i < count; ++i)
//{
// cout << recordSet->GetCurrentFieldValue(0) << " " << recordSet->GetCurrentFieldValue(1) << endl;
// recordSet->Move(1);
//}
//CDBIO *otherDb = NULL;
//otherDb = myDb.getDB();
////cout << "数据库类型:" << << endl;
//strSQL = "select * from person where age = 24";
////cout << myDb.ExecSQL(strSQL.c_str()) << endl;
//CMRRECORDSET *recordSet = NULL;
// otherDb->Select(strSQL.c_str(), &recordSet);
//int count = recordSet->GetRecordCount();
//cout << "查询记录总数:" << count << endl;
//for (int i = 0; i < count; ++i)
//{
// cout << recordSet->GetCurrentFieldValue(0) << " " << recordSet->GetCurrentFieldValue(1) << endl;
// recordSet->Move(1);
//}
string name ;
name = "www.mrong";
//char strInfo[30];
int age = 89;
char strSQL[40];
sprintf(strSQL,"insert into person values('%s',%d)",name.c_str(), age);
cout << strSQL << endl;
cout << myDb.ExecSQL(strSQL) << endl;
int wait;
cin >> wait;
return 0;
}
//
#include "stdafx.h"
#include <MRDBIO.h>
#include <DBIO.h>
#include <iostream>
#include <string>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
CMRDBIO myDb(DBTYPE::DB_MYSQL);
// string strSQL ;
//strSQL = "insert into person values('dfsdf', 24) ";
//cout << myDb.ExecSQL(strSQL.c_str()) << endl;
/* strSQL = "insert into person values('甘全福', 24) ";
cout << myDb.ExecSQL(strSQL.c_str()) << endl;*/
/* strSQL = "delete from person where name = '甘全福'";
myDb.ExecSQL(strSQL.c_str());
*/
//strSQL = "update person set age = 88 where name = 'fsdfdfds'";
//cout << myDb.ExecSQL(strSQL.c_str()) << endl;
//strSQL = "select * from person where age = 24";
////cout << myDb.ExecSQL(strSQL.c_str()) << endl;
//CMRRECORDSET *recordSet = NULL;
//myDb.Select(strSQL.c_str(), &recordSet);
//int count = recordSet->GetRecordCount();
//cout << "查询记录总数:" << count << endl;
//for (int i = 0; i < count; ++i)
//{
// cout << recordSet->GetCurrentFieldValue(0) << " " << recordSet->GetCurrentFieldValue(1) << endl;
// recordSet->Move(1);
//}
//CDBIO *otherDb = NULL;
//otherDb = myDb.getDB();
////cout << "数据库类型:" << << endl;
//strSQL = "select * from person where age = 24";
////cout << myDb.ExecSQL(strSQL.c_str()) << endl;
//CMRRECORDSET *recordSet = NULL;
// otherDb->Select(strSQL.c_str(), &recordSet);
//int count = recordSet->GetRecordCount();
//cout << "查询记录总数:" << count << endl;
//for (int i = 0; i < count; ++i)
//{
// cout << recordSet->GetCurrentFieldValue(0) << " " << recordSet->GetCurrentFieldValue(1) << endl;
// recordSet->Move(1);
//}
string name ;
name = "www.mrong";
//char strInfo[30];
int age = 89;
char strSQL[40];
sprintf(strSQL,"insert into person values('%s',%d)",name.c_str(), age);
cout << strSQL << endl;
cout << myDb.ExecSQL(strSQL) << endl;
int wait;
cin >> wait;
return 0;
}
相关文章推荐
- windows下使用C++操作MySQL数据库
- Android 存储学习之SQLite数据库的基本操作 (使用API操作数据库)
- 使用PHPMYADMIN操作mysql数据库添加新用户和数据库的方法
- ubuntu c++下连接mysql数据库和数据库的使用
- Python:操作PostgreSQL数据库(使用DB API2.0)
- Python:操作PostgreSQL数据库(使用DB API2.0)
- 使用Twisted的adbapi操作数据库
- 如何直接使用ODBC提供的API来操作数据库呢?
- 使用mysql C语言API编写程序—MYSQL数据库查询操作
- 操作、压缩MDB文件;使用ADO读写Mysql数据库;建立数据库和表的VBS脚本代码(2013-08-26 11:39:34)
- 使用纯C++实现SQL Server2005 数据库读写操作详细步骤
- 在Java的Spring框架的程序中使用JDBC API操作数据库
- SpringBoot中连接MYSQL数据库,并使用JPA进行数据库的相关操作
- SpringBoot中连接MYSQL数据库,并使用JPA进行数据库的相关操作
- windows下使用C++操作MySQL数据库
- 【MySql APIs】很完整的关于怎么用各种方法连接Mysql数据库,和使用API来操作Mysql数据库的资料
- 使用API方式操作数据库
- PHP数据库编程④使用php的mysqli扩展库操作mysql数据库
- 使用mysql C语言API编写程序—MYSQL数据库查询操作
- 哈工大 数据库实验2-使用高级语言操作MySQL数据库