本文整理汇总了C++中CppSQLite3DB::open方法的典型用法代码示例。如果您正苦于以下问题:C++ CppSQLite3DB::open方法的具体用法?C++ CppSQLite3DB::open怎么用?C++ CppSQLite3DB::open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CppSQLite3DB
的用法示例。
在下文中一共展示了CppSQLite3DB::open方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
}
示例2: 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();
}
}
示例3: 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();
}
示例4: OnBnClickedButtonSave
void CDlgProjectNew::OnBnClickedButtonSave()
{
// TODO: 在此添加控件通知处理程序代码
UpdateData(TRUE);
if (m_Edit_strProjectName.IsEmpty())
{
AfxMessageBox(_T("项目名称不能为空。"));
return;
}
if(IsExistProjectName(m_Edit_strProjectName)==true)
{
AfxMessageBox(_T("项目名称已存在,请重新输入。"));
return;
}
try{
CString strSQL;
CppSQLite3DB db;
db.open(CBoBoDingApp::g_strDatabasePath);//打开数据库
strSQL.Format(_T("INSERT INTO Project(ProjectName,AccountType,ShuoMing) VALUES('%s','%s','%s');"),m_Edit_strProjectName,m_Combo_strProjectClass,m_Edit_strInstruction);
db.execDML(strSQL);
}
catch (CppSQLite3Exception& e)
{
AfxMessageBox(e.errorMessage());
}
m_bIsSave=true;
OnOK();
}
示例5: CreateInfoByid
char* CreateInfoByid(int id)
{
static char buffer[1024]={0};
static char querybuf[1024]={0};
char* str = "%s 体力%s 武力%s 智力%s 魅力%s 年龄%s 类型 %s";
memset(querybuf,0,1024);
try
{ db.open("database/infodata.db");
sprintf(querybuf,"select heroinfo.name,ti,wu,zhi,mei,age,herotype.name from "
" heroinfo,herotype where heroinfo.id=%d and heroinfo.type=herotype.id;",id);
CppSQLite3Query q = db.execQuery(querybuf);
//nge_charsets_utf8_to_gbk((uint8*)str, (uint8*)querybuf, strlen(str), 1024);
if (!q.eof())
{
sprintf(buffer,str, q.fieldValue(0),q.fieldValue(1),q.fieldValue(2),q.fieldValue(3),
q.fieldValue(4),q.fieldValue(5),q.fieldValue(6));
}
db.close();
}catch (CppSQLite3Exception& e){
printf("%s\n",e.errorMessage());
}
return buffer;
}
示例6: GetValue
bool DBSetting::GetValue(long lKey,std::string &strValue)
{
//打开数据库
CppSQLite3DB dbTask;
dbTask.open(m_strDB.c_str());
CheckCreateSettingTable(dbTask);
CppSQLite3Buffer strSql;
try{
strSql.format("select value from T_Setting where key=%d;",lKey);
CppSQLite3Query q = dbTask.execQuery(strSql);
if (q.eof())
{
return false;
}
strValue = q.getStringField(0);
}
catch(CppSQLite3Exception &exp)
{
exp;
ATLTRACE("error:%s\n",exp.errorMessage());
ATLASSERT(FALSE);
return false;
}
return true;
}
示例7: 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;
}
}
示例8: grdErrorDetailSelectCell
void __fastcall TFrmAlarmDetailList::grdErrorDetailSelectCell(TObject *Sender, int ACol,
int ARow, bool &CanSelect)
{
TStringGrid* pGrid = ( TStringGrid* )Sender;
MemoSolution->Clear();
MemoCause->Clear();
if(CanSelect = true)
{
if(pGrid->Cells[ 1 ][ ARow ] != "" &&
pGrid->Cells[ 1 ][ ARow ] != "0" )
{
AnsiString szQuery = "SELECT * FROM " + g_szDBList[_nTableIndex];
INT nErrCode = pGrid->Cells[ 1 ][ ARow ].ToInt();
CppSQLite3DB dbMain;
dbMain.open( AnsiString( g_MainDBPath ).c_str() );
CppSQLite3Table tblAlarm = dbMain.getTable( szQuery.c_str() );
tblAlarm.setRow( nErrCode-1 );
const char* szCause = tblAlarm.getStringField( "cause", "" );
const char* szSolution = tblAlarm.getStringField( "solution", "" );
MemoCause->Lines->Add( szCause );
MemoSolution->Lines->Add( szSolution );
dbMain.close();
pGrid->Refresh();
}
}
}
示例9: 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());
}
}
示例10: IsExistProjectName
//void CDlgProjectNew::OnBnClickedButtonCancel()
//{
// // TODO: 在此添加控件通知处理程序代码
// m_bIsSave=false;
// OnOK();
//}
bool CDlgProjectNew::IsExistProjectName(CString strProjectName)//该产品名称是否存在库存表中 true 存在 false 不存在
{
CString strSQL;
strSQL.Format(_T("select count(ProjectName) as COUNTProjectName from Project where ProjectName='%s';"), strProjectName);
int nCount=0;
try
{
CppSQLite3DB db;
db.open(CBoBoDingApp::g_strDatabasePath);
CppSQLite3Query q = db.execQuery(strSQL);//销售单历史表
if (!q.eof())
{
//nCount=q.fieldValue(_T("COUNTPinMingGuiGe"));
nCount=q.getIntField(_T("COUNTProjectName"));
}
}
catch (CppSQLite3Exception& e)
{
AfxMessageBox(e.errorMessage());
}
if(nCount>0)
return true;
else
return false;
}
示例11: getFirstFile
int CDBObject::getFirstFile(char* name)
{
try
{
if(name != NULL)
{
char szSql[]= {"SELECT * from Record"};
CppSQLite3DB database;
database.open(g_szFile);
CppSQLite3Query query = database.execQuery(szSql);
if(!query.eof())
{
string path = query.getStringField(8);
string file= query.getStringField(7);
sprintf(name, "%s\\%s", UTF_82ASCII(path).c_str(), UTF_82ASCII(file).c_str());
return query.getIntField(0);
}
}
}
catch(...)
{
g_pLog->WriteLog("数据库查询异常 getFirstFile\n");
}
return -1;
}
示例12: 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);
*/
}
示例13: 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;
}
示例14: 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;
}
示例15: 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;
}