本文整理汇总了C++中CppSQLite3DB::execDML方法的典型用法代码示例。如果您正苦于以下问题:C++ CppSQLite3DB::execDML方法的具体用法?C++ CppSQLite3DB::execDML怎么用?C++ CppSQLite3DB::execDML使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CppSQLite3DB
的用法示例。
在下文中一共展示了CppSQLite3DB::execDML方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdatePKGParam
void CParamDB::UpdatePKGParam(PARAM_ITEM param)
{
CppSQLite3DB db;
try
{
if (FileExists(_sFilePath) == true)
{
db.open(AnsiString(_sFilePath).c_str());
String szSQL = " update RecipeParameter "
" set "
" Value = '" + FloatToStr(param.dValue) + "'"
" where group_idx = '" + IntToStr(param.nGroup_idx) + "'"
" and recipe_idx = '" + IntToStr(param.nRecipe_idx) + "'"
" and parameter_idx = '" + IntToStr(param.nParameter_idx) + "'";
db.execDML( "begin transaction;" );
db.execDML(AnsiString(szSQL).c_str());
db.execDML( "commit transaction;" );
db.close();
}
}
catch (Exception &e)
{
db.close();
}
}
示例2: CheckCreateSettingTable
bool CheckCreateSettingTable(CppSQLite3DB &dbTask)
{
try{
//如果表格不存在,则创建表格
if (!dbTask.tableExists("T_Setting")) //创建事件日志表
{
//数据库字段:任务id,任务类型,任务时间,上次提示时间,提示语句等。
//last_run_time可以用来辅助确定提示是否已经执行,避免重复
dbTask.execDML("Create table T_Setting("
"key integer , " //key
"value char[1024]);" //value
);
//为类型字段建立索引
dbTask.execDML("create index idx_id on T_Setting(key);");
}
return true;
}
catch(CppSQLite3Exception &exp)
{
exp;
ATLTRACE("error:%s\n",exp.errorMessage());
ATLASSERT(FALSE);
return false;
}
}
示例3: InsertPKGParam
void CParamDB::InsertPKGParam(PARAM_ITEM param)
{
CppSQLite3DB db;
try
{
if (FileExists(_sFilePath) == true)
{
db.open(AnsiString(_sFilePath).c_str());
String szSQL =
" insert into RecipeParameter "
" ( "
" group_idx, recipe_idx, parameter_idx , value "
" ) "
" values "
" ("
" '" + IntToStr(param.nGroup_idx) + "', "
" '" + IntToStr(param.nRecipe_idx) + "', "
" '" + IntToStr(param.nParameter_idx) + "', "
" '" + FloatToStr(param.dValue) + "') ";
db.execDML( "begin transaction;" );
db.execDML(AnsiString(szSQL).c_str());
db.execDML( "commit transaction;" );
db.close();
}
}
catch (Exception &e)
{
db.close();
}
}
示例4: DeletePKGParam
bool CParamDB::DeletePKGParam(int nGroup_no, int nRecipe_no)
{
CppSQLite3DB db;
bool bResult = false;
try
{
if (FileExists(_sFilePath) == true)
{
db.open(AnsiString(_sFilePath).c_str());
String szSQL =
" delete from RecipeParameter "
" where group_idx = '" + IntToStr(nGroup_no) + "'"
" and recipe_idx = '" + IntToStr(nRecipe_no) + "'";
db.execDML( "begin transaction;" );
bResult = db.execDML(AnsiString(szSQL).c_str());
db.execDML( "commit transaction;" );
db.close();
return bResult;
}
}
catch (Exception &e)
{
db.close();
return false;
}
}
示例5: JoinTableDelete
int CDbMeter::JoinTableDelete(const char* dbfilename)
{
try
{
CppSQLite3DB db;
db.open(dbfilename);
CppSQLite3Buffer bufSQL;
CppSQLite3Table t;
db.execDML("CREATE TABLE IF NOT EXISTS jointable (joinkey INTEGER PRIMARY KEY, EUI64ID CHAR(17), jointry INTEGER);");
bufSQL.format("SELECT * FROM jointable;");
t = db.getTable(bufSQL);
if( t.numRows() == 0 )
{
XDEBUG("Failure: Don't have JoinTable\r\n");
}
else
{
db.execDML("DROP TABLE joinTable;");
}
}
catch( CppSQLite3Exception& e )
{
XDEBUG("%s\r\n",e.errorMessage());
return e.errorCode();
}
return SQLITE_OK;
}
示例6: JoinTableAdd
int CDbMeter::JoinTableAdd(const char* dbfilename, char* szID)
{
try
{
CppSQLite3DB db;
db.open(dbfilename);
CppSQLite3Buffer bufSQL;
CppSQLite3Table t;
db.execDML("CREATE TABLE IF NOT EXISTS jointable (joinkey INTEGER PRIMARY KEY, EUI64ID CHAR(17), jointry INTEGER);");
bufSQL.format("SELECT * FROM jointable WHERE EUI64ID=%Q", szID);
t = db.getTable(bufSQL);
if( t.numRows() == 0 )
{
bufSQL.clear();
bufSQL.format("INSERT INTO jointable(EUI64ID, jointry) VALUES(%Q, %d);", szID, 0);
db.execDML(bufSQL);
}
else
XDEBUG("Jointable ID Duplicate!!\r\n");
db.close();
}
catch( CppSQLite3Exception& e )
{
XDEBUG("%s\r\n",e.errorMessage());
return e.errorCode();
}
return SQLITE_OK;
}
示例7: CheckCreateLogTable
bool CheckCreateLogTable(CppSQLite3DB &dbTask)
{
try{
//如果表格不存在,则创建表格
if (!dbTask.tableExists("T_log")) //创建事件日志表
{
//数据库字段:任务id,任务类型,任务时间,上次提示时间,提示语句等。
//last_run_time可以用来辅助确定提示是否已经执行,避免重复
dbTask.execDML("Create table T_log("
"id integer PRIMARY KEY AUTOINCREMENT, " //唯一id
"modal char[128],"
"time_log integer, " //时间
"type integer, " //状态
"value1 integer, " //值1
"value2 integer, " //值2
"message char[1024]);" //提示语句
);
//为类型字段建立索引
dbTask.execDML("create index idx_time on T_log(time_log);");
}
return true;
}
catch(CppSQLite3Exception &exp)
{
exp;
ATLTRACE("error:%s\n",exp.errorMessage());
ATLASSERT(FALSE);
return false;
}
}
示例8: OnBnClickedButtonRemove
void CMissedCallsDlg::OnBnClickedButtonRemove()
{
// TODO: Add your control notification handler code here
CString sDate, sTime, callee, callerID;
int nItem = m_list.GetNextItem(-1, LVNI_SELECTED);
if (nItem==-1)
return;
if (MessageBox(_("Are you sure you want to delete the selected items?"), APP_NAME, MB_YESNO | MB_ICONQUESTION)==IDYES) {
CppSQLite3DB db;
db.open(CStringA(OUTCALL_DB));
CString query, table;
if (m_cboShow.GetCurSel()==0)
table="MissedCalls";
else if (m_cboShow.GetCurSel()==1)
table="RecivedCalls";
else
table="PlacedCalls";
int nIndex;
try {
db.execDML("begin transaction");
while (nItem!=-1) { //from to time date
callerID = m_list.GetItemText(nItem, 0);
callee = m_list.GetItemText(nItem, 1);
sDate = m_list.GetItemText(nItem, 2);
nIndex = sDate.Find(_T(", "));
sTime = sDate.Mid(nIndex+2);
sDate = sDate.Mid(0, nIndex);
query = "delete from " + table + " where (CallerID='" + EscapeSQLString(callerID) + "' and Callee='" +
EscapeSQLString(callee) + "' and Date='" + sDate +"' and Time='" + sTime + "')";
db.execDML(query.GetBuffer());
m_list.DeleteItem(nItem);
nItem--;
nItem = m_list.GetNextItem(nItem, LVNI_SELECTED);
}
db.execDML("end transaction");
} catch (CppSQLite3Exception& e) { }
}
BOOL bEnable = (m_list.GetNextItem(-1, LVNI_SELECTED)!=-1)?TRUE:FALSE;
GetDlgItem(IDC_BUTTON_REMOVE)->EnableWindow(bEnable);
GetDlgItem(IDC_BUTTON_CALL)->EnableWindow(bEnable);
m_btnAddContact.EnableWindow(bEnable && (::theApp.GetProfileInt("Settings", "OutlookFeatures", 1)==1));
}
示例9: DeleteRecord
BOOL CDBObject::DeleteRecord(int nId)
{
char szSql[MAX_PATH] = {0};
sprintf_s(szSql, "delete from Record where id=%d", nId);
CppSQLite3DB db;
db.open(g_szFile);
int nRet2 = db.execDML("begin transaction;");
string strSql = szSql;
nRet2 = db.execDML(ASCII2UTF_8(strSql).c_str());
nRet2 = db.execDML("commit transaction;");
return TRUE;
}
示例10: InserSingleSetConfig
void CUserAcessSetDlg::InserSingleSetConfig()
{
CppSQLite3Table table;
CppSQLite3Query q;
CppSQLite3DB SqliteDBBuilding;
SqliteDBBuilding.open((UTF8MBSTR)g_strCurBuildingDatabasefilePath);
CString strSql;
strSql.Format(_T("select * from UserLevelSingleSet where MainBuilding_Name='%s' and Building_Name='%s' and username='%s'"),m_strMainBuilding,m_strSubNetName,m_strUserName);
q = SqliteDBBuilding.execQuery((UTF8MBSTR)strSql);
_variant_t temp_variant;
BOOL b_useLogin=false;
try
{
if(q.eof())
{
strSql.Format(_T("insert into UserLevelSingleSet values('%s','%s','%s',%i,%i)"),m_strMainBuilding,m_strSubNetName,m_strUserName,0,0);
SqliteDBBuilding.execDML((UTF8MBSTR)strSql);
}
SqliteDBBuilding.closedb();
}
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
}
}
示例11: db_Group_Create
//////////////////////////////////////////////////////////////////////////
// [3/21/2011 DHKim]
// 그룹 테이블 생성 Table( GroupKey PrimaryKey, GroupName TEXT)
//////////////////////////////////////////////////////////////////////////
int CDbMeter::db_Group_Create(const char* dbfilename)
{
try
{
CppSQLite3DB db;
db.open(dbfilename);
db.execDML("CREATE TABLE IF NOT EXISTS groups (GroupKey INTEGER PRIMARY KEY, GroupName TEXT);");
db.close();
}
catch ( CppSQLite3Exception& e )
{
return e.errorCode();
}
return SQLITE_OK;
/*
sqlite3* db = NULL;
if(sqlite3_open(dbfilename, &db) != SQLITE_OK)
{
XDEBUG("SQLite open failed: %s\r\n", sqlite3_errmsg(db));
return sqlite3_errcode(db);
}
if(sqlite3_exec(db, "CREATE TABLE IF NOT EXISTS groups (GroupKey) INTEGER PRIMARY KEY, GroupName TEXT", NULL, NULL, NULL) != SQLITE_OK)
{
XDEBUG("SQLite create failed: %s\r\n", sqlite3_errmsg(db));
return sqlite3_errcode(db);
}
sqlite3_close(db);
return sqlite3_errcode(db);
*/
}
示例12: JoinTableShow
int CDbMeter::JoinTableShow(const char* dbfilename)
{
try
{
CppSQLite3DB db;
db.open(dbfilename);
CppSQLite3Buffer bufSQL;
CppSQLite3Table t;
db.execDML("CREATE TABLE IF NOT EXISTS jointable (joinkey INTEGER PRIMARY KEY, EUI64ID CHAR(17), jointry INTEGER);");
bufSQL.format("SELECT * FROM jointable;");
t = db.getTable(bufSQL);
for ( int row = 0; row < t.numRows(); row++)
{
t.setRow(row);
for (int fld=0; fld<t.numFields(); fld++)
{
if( !t.fieldIsNull(fld))
XDEBUG("%s | ", t.fieldValue(fld));
}
XDEBUG("\r\n");
}
}
catch( CppSQLite3Exception& e )
{
XDEBUG("%s\r\n",e.errorMessage());
return e.errorCode();
}
return SQLITE_OK;
}
示例13: Log
void DBLog::Log( const char *pModel,int code,int value1,int value2, const char *pMessage )
{
//打开数据库
CppSQLite3DB dbTask;
dbTask.open(m_strDB.c_str());
CheckCreateLogTable(dbTask);
CppSQLite3Buffer strSql;
strSql.format("insert into T_Log values(NULL,'%q',%d,%d,%d,%d,'%q');",
pModel,GlobeFuns::TimeToInt(CTime::GetCurrentTime()),code,value1,value2,pMessage
);
try{
if(1!=dbTask.execDML(strSql))
{
ATLASSERT(FALSE);
return;
}
}
catch(CppSQLite3Exception &exp)
{
exp;
ATLTRACE("error:%s\n",exp.errorMessage());
ATLASSERT(FALSE);
return;
}
}
示例14: OnBnClickedButtonSave
void CDlgMemoAdd::OnBnClickedButtonSave()
{
// TODO: 在此添加控件通知处理程序代码
UpdateData(TRUE);
try{
CString strTime;
strTime =m_DateTime_valTime.Format(_T("%Y-%m-%d %H:%M"));
CString strSQL;
CppSQLite3DB db;
db.open(CBoBoDingApp::g_strDatabasePath);//打开数据库
strSQL.Format(_T("INSERT INTO Memo(MemoTime,Title,Content,CategoryName) VALUES('%s','%s','%s','%s');"),DealWithValue(strTime),DealWithValue(m_Edit_strTitle),DealWithValue(m_Edit_strContent),DealWithValue(m_Combo_strCategory));
db.execDML(strSQL);
}
catch (CppSQLite3Exception& e)
{
AfxMessageBox(e.errorMessage());
}
m_bIsSave=true;
OnOK();
}
示例15: dump
std::string CWRecorder::dump()
{
using namespace boost;
format day_fmt("%04d/%02d/%02d");
format time_fmt("%02d:%02d:%02d");
format table_name_fmt("%s_%04d%02d%02d_%02d%02d%02d");
// get current time
time_t raw_time;
tm* ptm;
time(&raw_time);
ptm = localtime(&raw_time);
day_fmt%(ptm->tm_year+1900)%(ptm->tm_mon+1)%(ptm->tm_mday);
time_fmt%(ptm->tm_hour)%(ptm->tm_min)%(ptm->tm_sec);
table_name_fmt%name()%(ptm->tm_year+1900)%(ptm->tm_mon+1)%(ptm->tm_mday)%(ptm->tm_hour)%(ptm->tm_min)%(ptm->tm_sec);
// add a record to RecordSummary table
CppSQLite3DB* db = MyDatabase::shared_output_database();
if(!db->tableExists("RecordSummary"))
{
throw HException("RecordSummary does not exist in output database");
}
format value_fmt("insert into RecordSummary values('%s','%s','%s')");
value_fmt%day_fmt.str()%time_fmt.str()%table_name_fmt.str();
db->execDML(value_fmt.str().c_str());
return table_name_fmt.str();
}