×

Discussion Board

Results 1 to 11 of 11
  1. #1
    Regular Contributor
    Join Date
    Oct 2008
    Posts
    323

    Question QSqlquery doubt?

    Dear All,

    Code:
    QSqlQuery query;
    query.exec(QString("select YES from NumTable where id = %1")
         .arg(item->id));
    i used the above query to get the YES column value with use of particular id.
    how to store the values of YES column into integer.
    Last edited by damodharan; 2010-05-26 at 13:37.

  2. #2
    Regular Contributor
    Join Date
    Oct 2008
    Posts
    323

    Question Re: QSqlquery doubt?

    Any one have idea about this?

  3. #3
    Regular Contributor
    Join Date
    Oct 2008
    Posts
    323

    Question Re: QSqlQuery Doubt ?

    Dear All,

    Code:
    class A
    --------
    
    int  i = iDB->EditFunctionality(item,item->id);
    
    i calling this function in Class B
    
    Class B
    -------
    
    int DB::EditFunctionality(FNumb* item,int id)
    {
    	bool ret = false;
    	QSqlQuery query;
    	int i;
    	query.exec(QString("select Enable from FTable where id = %1")
    		  .arg(item->id));
    	if (query.next()) 
    		{
    	        item->Enable = query.value(2).toInt();
    	        //How Can i Pass the ITEM->ENABLE VALUE INTO ANOTHER FUNCTION ?
                    //ITEM->ENABLE COLUMN CONTAINS 0 / 1
                      i = item->Enable;
    	        //ret = true;
    	    }
    
    	return i;
    }
    i tried some ways:
    stored that value into integer and pass that but i always passing "0" i don't know why?
    Last edited by damodharan; 2010-05-27 at 04:10.

  4. #4
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: QSqlquery doubt?

    I guess I'd pass the value as a parameter, or return it as the return value. What's your question?

    (And, BTW, why are you returning "i" when it has on value assigned?)

  5. #5
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: QSqlQuery Doubt ?

    Code:
    bool DB::EditFunctionality(FNumb *item)
    {
    	QSqlQuery query(QString("select Enable from FTable where id = %1").arg(item->id);
    	if (query.next()) 
                return query.value(0).toBool();
    
    	return false;
    }

  6. #6
    Regular Contributor
    Join Date
    Oct 2008
    Posts
    323

    Question Re: QSqlquery doubt?

    Quote Originally Posted by danhicksbyron View Post
    I guess I'd pass the value as a parameter, or return it as the return value. What's your question?

    (And, BTW, why are you returning "i" when it has on value assigned?)
    Dear danhicksbroyn,

    i am assigning i as item->Enable value

  7. #7
    Regular Contributor
    Join Date
    Oct 2008
    Posts
    323

    Question Re: QSqlQuery Doubt ?

    Quote Originally Posted by divanov View Post
    Code:
    bool DB::EditFunctionality(FNumb *item)
    {
    	QSqlQuery query(QString("select Enable from FTable where id = %1").arg(item->id);
    	if (query.next()) 
                return query.value(0).toBool();
    
    	return false;
    }
    Dear Divanov,

    thx,yeah i want to pass the return value of the particular column "ENABLE"
    but i am not understand why u mentioned return false.

  8. #8
    Regular Contributor
    Join Date
    Oct 2008
    Posts
    323

    Question Re: QSqlquery doubt?

    Dear All

    here is my code
    The i value always retruning "0"
    but the column value contains "1" also.

    what mistake in the below code?

    Code:
    void Edit::OpenEditor(QListWidgetItem* item1)
    {
    	int rowno = activeRow();
    	RowItems = iDBConnect->Selecting();
    
    	if(selectedRow == previousRow)
    	{
    		QString string1 = item1->text();
    		iFilterUpdate = new FilterUpdate();
    		iFilterUpdate->ui.lineEdit->setText(string1);
    		FilterNumb* item = RowItems[rowno];
    		iFilterUpdate->activeRow(item->id);
                    TInt i;
    		QSqlQuery query;
    		query.exec(QString("select Enable from FilterNumTable where id = %1")
    				  .arg(item->id));
    		if (query.next()) 
    			{
    				i = query.value(2).toBool();
                            }
    		if(i)
    			{
    				iFilterUpdate->ui.CheckEnable->setCheckState(Qt::Checked);
    			}
    		else
    			{
    				iFilterUpdate->ui.CheckDisable->setCheckState(Qt::Checked);
    			}
    	
    		this->close();
    	}
    	else
    	{
    		previousRow = selectedRow;
    	}
    }

  9. #9
    Regular Contributor
    Join Date
    Oct 2008
    Posts
    323

    Re: QSqlquery doubt?

    Dear all,

    problem sloved , thx for ur replies

  10. #10
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: QSqlQuery Doubt ?

    Quote Originally Posted by damodharan View Post
    thx,yeah i want to pass the return value of the particular column "ENABLE"
    but i am not understand why u mentioned return false.
    There are two reasons for that. First compilers kindly asks you and second is for the case when your table is empty.

  11. #11
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: QSqlquery doubt?

    Quote Originally Posted by damodharan View Post
    what mistake in the below code?
    Code:
    TInt i = query.value(2).toBool();
    Why do you need Symbian types in Qt code? It makes it non-portable. Why do you convert value to boolean and then to integer? It causes compiler warning and may confuse some reader. Why do you request third column as a resulting table has only one column?

Similar Threads

  1. doubt OfferKeyEventL and HandleCommandL
    By cruser11232 in forum Symbian User Interface
    Replies: 3
    Last Post: 2010-01-27, 11:08
  2. Active Objects doubt
    By mrlooper in forum Symbian
    Replies: 2
    Last Post: 2009-11-18, 07:09
  3. ELeave Doubt!
    By damodharan in forum Symbian
    Replies: 4
    Last Post: 2008-11-29, 08:13
  4. Doubt with Nokia 6020...
    By walabarse in forum General Messaging
    Replies: 0
    Last Post: 2006-03-31, 12:38
  5. Doubt about the working of ECOM
    By symsahoo in forum Symbian
    Replies: 0
    Last Post: 2005-10-14, 04:27

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×