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


C++ CppSQLite3DB类代码示例

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


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

示例1:

BOOL Maxthon3PlugIn::IsWorked()
{
	BOOL bRet = FALSE;

	if (m_pMemFavoriteDB)
	{
		CppSQLite3DB  objSqliteDatabase;

		objSqliteDatabase.openmem(m_pMemFavoriteDB, "");

		bRet = objSqliteDatabase.tableExists("MyFavNodes");

		if (bRet)
		{
			CppSQLite3Table objSqliteTable = objSqliteDatabase.getTable("select * from MyFavNodes");

			if (14 != objSqliteTable.numFields())
			{
				bRet = FALSE;
			}
		}
	}

	return bRet;
}
开发者ID:pyq881120,项目名称:urltraveler,代码行数:25,代码来源:Maxthon3PlugIn.cpp

示例2: TRACE

void CTerminateNewLocationDialog::OnSelchangeLocationlist() 
{
    int iLocationID = m_ctlLocationList.GetItemData(m_ctlLocationList.GetCurSel());
    CString sSQL;
    sSQL.Format("SELECT Industries.id,Industries.name FROM Industries,Sidings WHERE Industries.Sidings_FK=Sidings.id AND Sidings.Locations_FK=%d",iLocationID);
    TRACE(sSQL);
    //
    CppSQLite3DB* pDB = &((CTrainOpsApp*)AfxGetApp())->m_pDB;
    CppSQLite3Query q = pDB->execQuery(sSQL);
    //
    while( m_ctlIndustryList.GetCount() > 0 )
        m_ctlIndustryList.DeleteString(0);
    //
    while (!q.eof())
    {
        int nIndex = m_ctlIndustryList.AddString(q.getStringField("name"));
        m_ctlIndustryList.SetItemData(nIndex,q.getIntField("id"));
        q.nextRow();
    }
    //
    sSQL.Format("SELECT id,name FROM Sidings WHERE Locations_FK=%d;",iLocationID);
    q = pDB->execQuery(sSQL);
    //
    while( m_ctlSidingList.GetCount() > 0 )
        m_ctlSidingList.DeleteString(0);
    //
    while (!q.eof())
    {
        int nIndex = m_ctlSidingList.AddString(q.getStringField("name"));
        m_ctlSidingList.SetItemData(nIndex,q.getIntField("id"));
        q.nextRow();
    }
    q.finalize();
}
开发者ID:ibrahimelhadeg,项目名称:trainops,代码行数:34,代码来源:TerminateNewLocationDialog.cpp

示例3: Save

void CIndustryDetailDialog_Commodities::Save()
{
    CppSQLite3DB* pDB = &((CTrainOpsApp*)AfxGetApp())->m_pDB;
    //
    for( int i=0;i<m_ctlCommodityListIn.GetItemCount();i++ )
    {
        if( m_ctlCommodityListIn.GetCheck(i) )
        {
            int iCommodityFK = m_ctlCommodityListIn.GetItemData(i);
            int iLoadEmpty = atoi(m_ctlCommodityListIn.GetItemText(i,1));
            int iQuanHigh = atoi(m_ctlCommodityListIn.GetItemText(i,2));
            int iQuanLow = atoi(m_ctlCommodityListIn.GetItemText(i,3));
            int iPercent = atoi(m_ctlCommodityListIn.GetItemText(i,4));
            CString sSQL;
            sSQL.Format("INSERT INTO Industries_Commodities (Industries_FK,Commodities_FK,InOut,LoadEmptyDays,Quantity_low,Quantity_high,Quantity_percentage) VALUES (%d,%d,0,%d,%d,%d,%d);",m_iIndustryID,iCommodityFK,iLoadEmpty,iQuanLow,iQuanHigh,iPercent);
            CppSQLite3Query q = pDB->execQuery(sSQL);
            q.finalize();
        }
    }
    for( i=0;i<m_ctlCommodityListOut.GetItemCount();i++ )
    {
        if( m_ctlCommodityListOut.GetCheck(i) )
        {
            int iCommodityFK = m_ctlCommodityListOut.GetItemData(i);
            int iLoadEmpty = atoi(m_ctlCommodityListOut.GetItemText(i,1));
            int iQuanHigh = atoi(m_ctlCommodityListOut.GetItemText(i,2));
            int iQuanLow = atoi(m_ctlCommodityListOut.GetItemText(i,3));
            int iPercent = atoi(m_ctlCommodityListOut.GetItemText(i,4));
            CString sSQL;
            sSQL.Format("INSERT INTO Industries_Commodities (Industries_FK,Commodities_FK,InOut,LoadEmptyDays,Quantity_low,Quantity_high,Quantity_percentage) VALUES (%d,%d,1,%d,%d,%d,%d);",m_iIndustryID,iCommodityFK,iLoadEmpty,iQuanLow,iQuanHigh,iPercent);
            CppSQLite3Query q = pDB->execQuery(sSQL);
            q.finalize();
        }
    }
}
开发者ID:ibrahimelhadeg,项目名称:trainops,代码行数:35,代码来源:IndustryDetailDialog_Commodities.cpp

示例4: UpdateData

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();
}
开发者ID:boboding,项目名称:Boboding,代码行数:32,代码来源:DlgProjectNew.cpp

示例5: count

//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;

}
开发者ID:boboding,项目名称:Boboding,代码行数:36,代码来源:DlgProjectNew.cpp

示例6: UpdateData

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();
}
开发者ID:boboding,项目名称:Boboding,代码行数:25,代码来源:DlgMemoAdd.cpp

示例7: 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();
		}
	}        
}
开发者ID:japgo,项目名称:mygithub,代码行数:35,代码来源:AlarmDetailScrn.cpp

示例8: day_fmt

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();
}
开发者ID:lixiangalwh,项目名称:carworld-0.245.1-add-new-feature,代码行数:29,代码来源:CWRecorder.cpp

示例9: UpdateData

void CCarTypesDetailDialog::OnOK() 
{
	// TODO: Add extra validation here

    UpdateData();
    //
    CppSQLite3DB* pDB = &((CTrainOpsApp*)AfxGetApp())->m_pDB;
    CString sSQL;
    //
    //  add?
    //
    if( m_iCarTypeFK == -1 )
    {
        sSQL.Format("SELECT 1 FROM CarTypes WHERE type_id=\"%s\"",m_sCarTypeID);
        CppSQLite3Query q = pDB->execQuery((LPCTSTR)sSQL);
        //
        if(!q.eof())
        {
            MessageBox("Duplcate Type ID!","LSC TrainOps Error",MB_ICONSTOP|MB_OK);
            return;
        }
        sSQL.Format("INSERT INTO CarTypes (id,type_id,description,active,passenger) VALUES (NULL,\"%s\",\"%s\",1,%d)",m_sCarTypeID,m_sCarTypeDescription,m_bPassenger?1:0);
    }
    else
    {
        sSQL.Format("UPDATE CarTypes SET type_id=\"%s\",description=\"%s\",passenger=%d WHERE id=%d",m_sCarTypeID,m_sCarTypeDescription,m_bPassenger?1:0,m_iCarTypeFK);
    }
    pDB->execDML((LPCTSTR)sSQL);
    
	CDialog::OnOK();
}
开发者ID:ibrahimelhadeg,项目名称:trainops,代码行数:31,代码来源:CarTypesDetailDialog.cpp

示例10: LoadParameter

// ---------------------------------------------------------------------------
CppSQLite3Table CParamDB::LoadParameter(int nCategory)
{
	CppSQLite3DB db;
	CppSQLite3Table qryTable;

	try
	{
		if (FileExists(_sFilePath) == true)
		{
			db.open(AnsiString(_sFilePath).c_str());

			String szSQL = " select * from Parameter "
						   " where name <> ''"
//							" where category = '" + GetCategory(nCategory) + "'"
//							" or category = '3'"
							" order by idx ";

			qryTable = db.getTable(AnsiString(szSQL).c_str());
		}
	}
	catch (Exception &e)
	{

	}

	db.close();
	return qryTable;
}
开发者ID:japgo,项目名称:mygithub,代码行数:29,代码来源:uParamDB.cpp

示例11: dump

// xian modify so that save faster
std::string VehicleStateRecorder::dump()
{
	using namespace boost;
	string table = BaseT::dump();
	
	CppSQLite3DB* db = MyDatabase::shared_output_database();

	format fmt = format("create table %s (i int, elapsed_time double,x double, y double, z double)")%table;
	// creat a new record table
	db->execDML(
		fmt.str().c_str()
	);

	// using the table name as the fle name to generate a data file
	 fmt = format(CommandOption::Option().OutDir+"\\%s")%table;
	ofstream outf(fmt.str().c_str());


	// record the stuff
	unsigned int i=0;
	BOOST_FOREACH(BaseItemPtrT& p_record,m_Records)
	{
		ItemPtrT p = static_pointer_cast<ItemT>(p_record);
		if(p)
		{
			Point3D& pos = p->m_State.m_Ref.Position;
			//format fmt = format("insert into %s values(%d, %f, %f, %f, %f)")%table%i%(p->m_TimeElapse)%pos.x()%pos.y()%pos.z();
			//db->execDML(fmt.str().c_str());  db saving too slow, direct save
			format fmt = format("%d, %f, %f, %f, %f")%i%(p->m_TimeElapse)%pos.x()%pos.y()%pos.z();
			outf<<fmt.str().c_str()<<endl;
			++i;
		}
	}
开发者ID:lixiangalwh,项目名称:carworld-0.245.1-add-new-feature,代码行数:34,代码来源:CWRecorder.cpp

示例12: 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());
	}



}
开发者ID:Fance,项目名称:T3000_Building_Automation_System,代码行数:34,代码来源:UserAcessSetDlg.cpp

示例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;
}
开发者ID:bearxiong99,项目名称:new_swamm,代码行数:29,代码来源:DbMeter.cpp

示例14: 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;
}
开发者ID:curious-boy,项目名称:RMS,代码行数:25,代码来源:DBObject.cpp

示例15: 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);
	*/
}
开发者ID:bearxiong99,项目名称:new_swamm,代码行数:39,代码来源:DbMeter.cpp


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