当前位置: 首页>>代码示例>>C++>>正文


C++ DBConn类代码示例

本文整理汇总了C++中DBConn的典型用法代码示例。如果您正苦于以下问题:C++ DBConn类的具体用法?C++ DBConn怎么用?C++ DBConn使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DBConn类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SelectSignle

string UserService::SelectSignle(string u_id){
	DBConn db;
	string sql=SELECT_SINGLE_USER_SQL+Utils::AddSingleQuoteMark(u_id);
	string res=db.Query_single_mysql(sql);
	db.Close_mysql();
	return res;
}
开发者ID:xjtuse2014,项目名称:IPMP_10.8,代码行数:7,代码来源:UserService.cpp

示例2: ok

void LoginDialog::ok()
{
	DBConn* conn = DBService::getInstance()->getConnection();
	if (!conn->isConnected())
	{
		QMessageBox::critical(NULL, "Ошибка БД", "Нет подключения к БД");
		reject();
	}

	QString sql =
			QString("SELECT count(*) FROM users WHERE user_name = \'%1\' AND password = \'%2\'")
			.arg(name->text(), passwd->text());
	QSqlQuery q = conn->executeQuery(sql);
	bool res = false;
	if (q.isActive() && q.next())
	{
		res = q.value(0).toInt() > 0;
	}

	if (res == false)
	{
		QMessageBox::warning(NULL, "Предупреждение", "Неверный пароль");
	}
	else
	{
		accept();
	}
}
开发者ID:dpodchernyaev,项目名称:salon,代码行数:28,代码来源:login_dialog.cpp

示例3: selectAllAdmin

/* 查询所有管理员*/
string AdminService::selectAllAdmin(){
	DBConn db;
	string res = db.Query_all_mysql(SELECT_ALL_ADMIN_SQL, "Admin");
cout<<"AdminService::selectAllAdmin(), res="<<res<<endl;
    db.Close_mysql();
    return res;
}
开发者ID:xjtuse2014,项目名称:IPMP_10.8,代码行数:8,代码来源:AdminService.cpp

示例4: SelectSignle

string FacilityService::SelectSignle(string id) {
    string sql = "select * from facility where facility_id="
                 + Utils::AddSingleQuoteMark(id);
    DBConn db;
    string res = db.Query_single_mysql(sql);
    return res;
}
开发者ID:xjtuse2014,项目名称:IPMP-1,代码行数:7,代码来源:FacilityService.cpp

示例5: SelectMeetroomExist

int MeetroomService::SelectMeetroomExist(string mr_id){
	DBConn db;
	string sql=SELECT_MR_ID_SQL+Utils::AddSingleQuoteMark(mr_id);
	string res=db.Query_mysql(sql);
	if(res.empty()==true){
		return 0;
	}
	return -1;
}
开发者ID:xjtuse2014,项目名称:IPMP-1,代码行数:9,代码来源:MeetroomService.cpp

示例6: SelectAll

string UserService::SelectAll(){
	DBConn db;
	string res=db.Query_all_mysql(SELECT_ALL_USER_SQL,"Users");
cout<<"i'm return back from Db.query_all_sql,result="<<res<<endl;
	db.Close_mysql();
cout<<"i'm in the UserService SelectAll:res="<<endl;
	return res;

}
开发者ID:xjtuse2014,项目名称:IPMP_10.8,代码行数:9,代码来源:UserService.cpp

示例7: UpdateForRoom

//为会议室添加设备 成功
int FacilityService::UpdateForRoom(string id,string mr_id) {
    string sql = "update facility set meetroom_id = '"  + mr_id + "' where facility_id = " + Utils::AddSingleQuoteMark(id);
    DBConn db;
    if (db.Execute_mysql(sql) == 0) {
        db.Close_mysql();
        return 330;
    } else
        db.Close_mysql();
    return 331;
}
开发者ID:xjtuse2014,项目名称:IPMP-1,代码行数:11,代码来源:FacilityService.cpp

示例8: selectSingleAdmin

/*按id查询单个管理员*/
string AdminService::selectSingleAdmin(string a_id){
cout<<"AdminService::slelectSingleAdmin  ---------i'm here"<<endl;
	DBConn db;
	string sql = SELECT_SINGLE_ADMIN_SQL+Utils::AddSingleQuoteMark(a_id);
cout<<"select single sql= "<<sql<<endl;
	string res = db.Query_single_mysql(sql);
cout<<"AdminService::selectSingleAdmin(), res="<<res<<endl;
	db.Close_mysql();
	return res;
}
开发者ID:xjtuse2014,项目名称:IPMP_10.8,代码行数:11,代码来源:AdminService.cpp

示例9: doJob

void DBConnQueryWorker::doJob(DBConnQueryJobPtr job) {
  string &sql = job->m_sql;
  Util::replaceAll(sql, "INDEX", lexical_cast<string>(job->m_index).c_str());

  if (!job->m_server) {
    job->m_affected = -1;
    job->m_error.code = -1;
    job->m_error.msg = "(server info missing)";
    return;
  }

  try {
    DBConn conn;
    int count = 0;
  retry:
    try {
      count++;
      conn.open(job->m_server, job->m_connectTimeout, job->m_readTimeout);
    } catch (DatabaseException &e) {
      if (job->m_retryQueryOnFail &&
          count <= job->m_maxRetryQueryOnFail) {
        goto retry;
      } else {
        throw;
      }
    }

    if (job->m_dsResult) {
      DBDataSet ds;
      job->m_affected = conn.execute(sql.c_str(), &ds,
                                     job->m_retryQueryOnFail);
      Lock lock(*job->m_dsMutex);
      job->m_dsResult->addDataSet(ds);
    } else {
      job->m_affected = conn.execute(sql.c_str(), nullptr,
                                     job->m_retryQueryOnFail);
    }
  } catch (DatabaseException &e) {
    job->m_affected = -1;
    job->m_error.code = e.m_code;
    job->m_error.msg = e.getMessage();
  } catch (Exception &e) {
    job->m_affected = -1;
    job->m_error.code = -1;
    job->m_error.msg = e.getMessage();
  } catch (std::exception &e) {
    job->m_affected = -1;
    job->m_error.code = -1;
    job->m_error.msg = e.what();
  } catch (...) {
    job->m_affected = -1;
    job->m_error.code = -1;
    job->m_error.msg = "(unknown exception)";
  }
}
开发者ID:HendrikGrunstra,项目名称:hiphop-php,代码行数:55,代码来源:db_conn.cpp

示例10: SelectUserExist

int UserService::SelectUserExist(string u_id){
	DBConn db;
	string sql="select u_name from user where u_id='"+u_id+"'";
	string res=db.Query_mysql(sql);
	if(res.empty()==true){
		cout<<"无重复,可插入!"<<endl;
		return 0;
	}
	cout<<"重复,不可插入!"<<endl;
	return -1;
}
开发者ID:xjtuse2014,项目名称:IPMP_10.8,代码行数:11,代码来源:UserService.cpp

示例11: deleteSingleAdmin

/**
 * return 106;//管理删除成功
 * return 107;//管理员删除失败
 */
int AdminService::deleteSingleAdmin(string a_id){

	string sql="delete from admin where a_id="+Utils::AddSingleQuoteMark(a_id);
		DBConn db;
		if(db.Execute_mysql(sql)==0){
			db.Close_mysql();
				return 106;
		}else{
			db.Close_mysql();
				return 107;
		}
}
开发者ID:xjtuse2014,项目名称:IPMP_10.8,代码行数:16,代码来源:AdminService.cpp

示例12: deleteAllAdmin

/**
 * return 106;//管理删除成功
 * return 107;//管理员删除失败
 */
int AdminService::deleteAllAdmin(){

	string sql="delete from admin";
	DBConn db;
	if(db.Execute_mysql(sql)==0){
		db.Close_mysql();
		return 108;
	}else{
		db.Close_mysql();
		return 109;
	}
}
开发者ID:xjtuse2014,项目名称:IPMP_10.8,代码行数:16,代码来源:AdminService.cpp

示例13: DeleteSignle

int MeetroomService::DeleteSignle(string mr_id){
	string sql=DELETE_SINGLE_MR_SQL+Utils::AddSingleQuoteMark(mr_id);
	DBConn db;
	if(db.Execute_mysql(sql)==0){
		db.Close_mysql();
			return 410;
	}else{
		db.Close_mysql();
			return 411;
	}

}
开发者ID:xjtuse2014,项目名称:IPMP-1,代码行数:12,代码来源:MeetroomService.cpp

示例14: DeleteSignle

int UserService::DeleteSignle(string u_id){
	string sql="delete from user where u_id="+Utils::AddSingleQuoteMark(u_id);
	DBConn db;
	if(db.Execute_mysql(sql)==0){
		db.Close_mysql();
			return 400;
	}else{
		db.Close_mysql();
			return 401;
	}

}
开发者ID:xjtuse2014,项目名称:IPMP_10.8,代码行数:12,代码来源:UserService.cpp

示例15: LoginSys

/**
 * return 100;//登录成功
 * return 101;//登录失败 :密码错误
 * return 102;//登录失败:ID不存在
 */
int AdminService::LoginSys(string a_id,string a_psd){
	DBConn db;
	string sql="select a_psd from admin where a_id="+Utils::AddSingleQuoteMark(a_id);
	string res=db.Query_mysql(sql);
	if(res.empty()==true){
		return 102;
	}else if(res==a_psd){
		return 100;
	}else{
		return 101;
	}
}
开发者ID:xjtuse2014,项目名称:IPMP-1,代码行数:17,代码来源:AdminService.cpp


注:本文中的DBConn类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。