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


C++ CppSQLite3Table::getStringField方法代码示例

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


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

示例1: 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

示例2: AnsiString

void	TfrmUseSkipViewer::LoadUseSkipNameFromDB()
{       
    CppSQLite3DB db;
	String szSelectQuery = "SELECT * FROM UseSkip";

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

            CppSQLite3Table table = db.getTable( AnsiString( szSelectQuery ).c_str() );

            if( table.numRows() != 0 )
            {
                for( int row = 0; row < table.numRows(); row++ )
                {
                    table.setRow( row );
                    String szName = table.getStringField( "name", "NULL" );
                    
                    if( szName == "NULL" || szName == "" )
                    {
                        szName = "UseSkip" + IntToStr( row );
                    }
                    
                    ComboBoxUseSkip->AddItem( szName, NULL );
                }
    		}
            db.close();
		}
	}
	catch(Exception &e)
	{
		db.close();
		ShowMessage("Use Skip DB select error! : " + e.Message);
	}       
}
开发者ID:japgo,项目名称:mygithub,代码行数:37,代码来源:FrmUseSkipViewerScrn.cpp

示例3: main

int main(int argc, char** argv)
{
    try
    {
		int row;
        CppSQLite3DB db;

        cout << "SQLite Header Version: " << CppSQLite3DB::SQLiteHeaderVersion() << endl;
        cout << "SQLite Library Version: " << CppSQLite3DB::SQLiteLibraryVersion() << endl;
        cout << "SQLite Library Version Number: " << CppSQLite3DB::SQLiteLibraryVersionNumber() << endl;

        remove(gszFile);
        db.open(gszFile);

        ////////////////////////////////////////////////////////////////////////////////
        // Demonstrate getStringField(), getIntField(), getFloatField()
        ////////////////////////////////////////////////////////////////////////////////
        db.execDML("create table parts(no int, name char(20), qty int, cost number);");
        db.execDML("insert into parts values(1, 'part1', 100, 1.11);");
        db.execDML("insert into parts values(2, null, 200, 2.22);");
        db.execDML("insert into parts values(3, 'part3', null, 3.33);");
        db.execDML("insert into parts values(4, 'part4', 400, null);");

        cout << endl << "CppSQLite3Query getStringField(), getIntField(), getFloatField() tests" << endl;
        CppSQLite3Query q = db.execQuery("select * from parts;");
        while (!q.eof())
        {
            cout << q.getIntField(0) << "|";
            cout << q.getStringField(1) << "|";
            cout << q.getInt64Field(2) << "|";
            cout << q.getFloatField(3) << "|" << endl;
            q.nextRow();
        }

        cout << endl << "specify NULL values tests" << endl;
        q = db.execQuery("select * from parts;");
        while (!q.eof())
        {
            cout << q.getIntField(0) << "|";
            cout << q.getStringField(1, "NULL") << "|";
            cout << q.getIntField(2, -1) << "|";
            cout << q.getFloatField(3, -3.33) << "|" << endl;
            q.nextRow();
        }

        cout << endl << "Specify fields by name" << endl;
        q = db.execQuery("select * from parts;");
        while (!q.eof())
        {
            cout << q.getIntField("no") << "|";
            cout << q.getStringField("name") << "|";
            cout << q.getInt64Field("qty") << "|";
            cout << q.getFloatField("cost") << "|" << endl;
            q.nextRow();
        }

        cout << endl << "specify NULL values tests" << endl;
        q = db.execQuery("select * from parts;");
        while (!q.eof())
        {
            cout << q.getIntField("no") << "|";
            cout << q.getStringField("name", "NULL") << "|";
            cout << q.getIntField("qty", -1) << "|";
            cout << q.getFloatField("cost", -3.33) << "|" << endl;
            q.nextRow();
        }
		q.finalize();

		////////////////////////////////////////////////////////////////////////////////
        // Demonstrate getStringField(), getIntField(), getFloatField()
		// But this time on CppSQLite3Table
        ////////////////////////////////////////////////////////////////////////////////
        cout << endl << "CppSQLite3Table getStringField(), getIntField(), getFloatField() tests" << endl;
        CppSQLite3Table t = db.getTable("select * from parts;");
        for (row = 0; row < t.numRows(); row++)
        {
            t.setRow(row);
            cout << t.getIntField(0) << "|";
            cout << t.getStringField(1) << "|";
            cout << t.getIntField(2) << "|";
            cout << t.getFloatField(3) << "|" << endl;
        }

        cout << endl << "specify NULL values tests" << endl;
        for (row = 0; row < t.numRows(); row++)
        {
            t.setRow(row);
            cout << t.getIntField(0, -1) << "|";
            cout << t.getStringField(1, "NULL") << "|";
            cout << t.getIntField(2, -1) << "|";
            cout << t.getFloatField(3, -3.33) << "|" << endl;
        }

        cout << endl << "Specify fields by name" << endl;
        for (row = 0; row < t.numRows(); row++)
        {
            t.setRow(row);
            cout << t.getIntField("no") << "|";
            cout << t.getStringField("name") << "|";
            cout << t.getIntField("qty") << "|";
//.........这里部分代码省略.........
开发者ID:Omgan,项目名称:CppSQLite,代码行数:101,代码来源:CppSQLite3DemoExt.cpp


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