Home » Community » Newbie corner » gridctrl with sql
gridctrl with sql [message #34010] |
Sun, 09 October 2011 07:03  |
|
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   |
|
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   |
|
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   |
|
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
|
|
|
|
Goto Forum:
Current Time: Sat Apr 26 14:36:25 CEST 2025
Total time taken to generate the page: 0.01151 seconds
|