您的位置:首页 > 编程语言 > C语言/C++

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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: