本文整理汇总了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;
}
示例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();
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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)";
}
}
示例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;
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}