Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
How to Store Query in Array to Display in Grid
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
dev  
View profile  
 More options Oct 7 2011, 3:45 am
From: dev <drtzuihg...@trashemail.de>
Date: Fri, 7 Oct 2011 00:45:54 -0700 (PDT)
Local: Fri, Oct 7 2011 3:45 am
Subject: [wxDba]How to Store Query in Array to Display in Grid
Hello,
after successfully building wxbda and dba, I'm trying to display the
query result in a DataGrid. My Problem is, that there is only the last
query result in each row of my DataGrid.

I'm using following code:

wxString qryresult;

wxdba::SQL selec(wxdba::SQL(_T("SELECT * FROM
mydatabase")).into(qryresult));
        std::auto_ptr<wxdba::DbResult> res(ar-

>GetIStream().SendQuery(selec));

while(res->FetchRow())
        {
                for(int i = 0; i < RowCount; i++)
        {
                for( int a = 0; a < ColumnCount; a++)
                {
                        grd_Table->SetCellValue(i,a,qryresult);
                }
       }
       }

What's wrong?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "[wxDba]How to Store Query in Array to Display in Grid" by Lukasz Michalski
Lukasz Michalski  
View profile  
 More options Oct 7 2011, 3:58 am
From: Lukasz Michalski <l...@zork.pl>
Date: Fri, 07 Oct 2011 09:58:25 +0200
Local: Fri, Oct 7 2011 3:58 am
Subject: Re: [Debea] [wxDba]How to Store Query in Array to Display in Grid
On 10/07/2011 09:45 AM, dev wrote:

> Hello,
> after successfully building wxbda and dba, I'm trying to display the
> query result in a DataGrid. My Problem is, that there is only the last
> query result in each row of my DataGrid.

> I'm using following code:

> wxString qryresult;

> wxdba::SQL selec(wxdba::SQL(_T("SELECT * FROM
> mydatabase")).into(qryresult));
>    std::auto_ptr<wxdba::DbResult> res(ar-
>> GetIStream().SendQuery(selec));

This will read X columns from mydatabase table and stores value of the
last one into qryresult. You need to provide as many variables as
columns that you fetch from the table, e.g.:

wxString a,b,c;

wxdba::SQL select(wxdba::SQL(_T("SELECT a,b,c FROM
mydatabase")).into(a).into(b).into(c));

> while(res->FetchRow())
>    {
>            for(int i = 0; i < RowCount; i++)
>    {
>            for( int a = 0; a < ColumnCount; a++)
>            {
>                    grd_Table->SetCellValue(i,a,qryresult);
>            }
>        }
>        }

If you do not know the number of columns then use res->Columns() and
res->GetString(int) to get values instead of into():

while(res->FetchRow()) {
        for (int i = 0; i < res->Columns(); i++) {
                grd_Table->SetCellValue(i,a,res->GetString(i));
        }

}

Regards,
Łukasz

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "How to Store Query in Array to Display in Grid" by dev
dev  
View profile  
 More options Oct 7 2011, 4:36 am
From: dev <drtzuihg...@trashemail.de>
Date: Fri, 7 Oct 2011 01:36:08 -0700 (PDT)
Local: Fri, Oct 7 2011 4:36 am
Subject: Re: [wxDba]How to Store Query in Array to Display in Grid
Thanks for your quick reply.
Now it shows the appropriate ID but it's still the last record.

wxdba::SQL selec(wxdba::SQL(_T("SELECT * FROM mydatabase")));
while(res->FetchRow())
        {
                for(int i = 0; i < RowCount; i++)
        {

                for( int a = 0; a < ColumnCount; a++)
                {
                        grd_Table->SetCellValue(i,a,res->GetString(a));

                }
                }
        }


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "[wxDba]How to Store Query in Array to Display in Grid" by Lukasz Michalski
Lukasz Michalski  
View profile  
 More options Oct 7 2011, 4:42 am
From: Lukasz Michalski <l...@zork.pl>
Date: Fri, 07 Oct 2011 10:42:42 +0200
Local: Fri, Oct 7 2011 4:42 am
Subject: Re: [Debea] Re: [wxDba]How to Store Query in Array to Display in Grid
On 10/07/2011 10:36 AM, dev wrote:

What does the RowCount and ColumnCount variable is set to? RowCount does
not make any sense to me - FetchRow() moves to the next row in DbResult.

Regards,
Łukasz


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "How to Store Query in Array to Display in Grid" by dev
dev  
View profile  
 More options Oct 7 2011, 5:34 am
From: dev <drtzuihg...@trashemail.de>
Date: Fri, 7 Oct 2011 02:34:48 -0700 (PDT)
Local: Fri, Oct 7 2011 5:34 am
Subject: Re: [wxDba]How to Store Query in Array to Display in Grid
I changed my code to:
int b = 0;
        while(res2->FetchRow())
        {

                for( int a = 0; a < res->Columns(); a++)
                {
                        grd_Table->SetCellValue(b,a,res2->GetString(a));
                }
                b++;
        }

and it works now!
There's one question remaining: How can i Display additional
character? Like öäü etc.?
The Cell is empty, when the value contains an additional character.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "[wxDba]How to Store Query in Array to Display in Grid" by Lukasz Michalski
Lukasz Michalski  
View profile  
 More options Oct 7 2011, 7:03 am
From: Lukasz Michalski <l...@zork.pl>
Date: Fri, 07 Oct 2011 13:03:08 +0200
Local: Fri, Oct 7 2011 7:03 am
Subject: Re: [Debea] Re: [wxDba]How to Store Query in Array to Display in Grid
On 10/07/2011 11:34 AM, dev wrote:

It depends on your database. The key is to set the same enconding in
SetConversionSpecs as your database uses.

(default is UTF8, so if your database uses UTF-8 encoding then it should
work out of the box)

Regards,
Łukasz


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »