Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » gridctrl with sql
gridctrl with sql [message #34010] Sun, 09 October 2011 07:03 Go to next message
mtdew3q is currently offline  mtdew3q
Messages: 181
Registered: July 2010
Location: Upstate, NY (near Canada)
Experienced Member

Hi-

In the code below it adds the fields to the grid funny.
The values are off by one in the order they are added to the grid.

For i.e. sql[0] value is 1 but sql[1] abcd value is added in the
first column to the grid. So instead of:
1 | abcd : I get abcd in column 1.

I am using postgresql. Any ideas how I can get the sql result set
to appear in the correct columns in the grid?

thanks - jim

void ListMiser::LoadProducts()
{

SqlId all("*");
Sql sql(m_session);
sql.ClearError();
products.Clear();

sql * Select(all).From(PRODUCTS).Where(product_id ==1);

while(sql.Fetch()){

products.Add(sql);
Cout() << sql[0] << " " << sql[5] << " \'" << "\'\n";
}
}


Re: gridctrl with sql [message #34011 is a reply to message #34010] Sun, 09 October 2011 07:19 Go to previous messageGo to next message
mtdew3q is currently offline  mtdew3q
Messages: 181
Registered: July 2010
Location: Upstate, NY (near Canada)
Experienced Member

quick addendum:

struct ConvInt : Convert
{
Value Format(const Value &q) const
{
return q.IsNull() ? Null : UPP::Format("%i", q);
}
};

%i %d fail

%` works

the column is SERIAL

thanks for any assistance--
Re: gridctrl with sql [message #34012 is a reply to message #34010] Sun, 09 October 2011 07:38 Go to previous messageGo to next message
mtdew3q is currently offline  mtdew3q
Messages: 181
Registered: July 2010
Location: Upstate, NY (near Canada)
Experienced Member

I think I figured it out. If I add a column and index with the same name it acts funny.

I will adjust my index and column names closer to the example
files.

thanks and sorry.

jim
Re: gridctrl with sql [message #34013 is a reply to message #34012] Sun, 09 October 2011 11:24 Go to previous messageGo to next message
mtdew3q is currently offline  mtdew3q
Messages: 181
Registered: July 2010
Location: Upstate, NY (near Canada)
Experienced Member

another thing that had me stuck for a while is I needed to use
sequences. i picked that trick up from the threads in the sql forum. i was able to cross reference the postgresql manual on that topic.

thanks for that,
later


Re: gridctrl with sql [message #34029 is a reply to message #34012] Tue, 11 October 2011 20:30 Go to previous message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
mtdew3q wrote on Sun, 09 October 2011 07:38

I think I figured it out. If I add a column and index with the same name it acts funny.

I will adjust my index and column names closer to the example
files.

thanks and sorry.

jim


Hello,

I have observed the same problem but I believed to hase misused the ctrl.
Perhaps two more words about index could clarify how to use it.

Luigi
Previous Topic: Creating a form inside a DLL
Next Topic: Linking error with gdk_pixbuf-2.0
Goto Forum:
  


Current Time: Fri Apr 19 12:35:38 CEST 2024

Total time taken to generate the page: 0.03521 seconds