Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hello everyone!

I would like to start by saying thanks to everyone who takes some time to view this thread and try to help.

I will be brief, and cut to the point:

I work on Windows XP, in MS Visual Studio C++, using ADO to query MS Access 2007 database with this query:

C++
wchar_t *query = L"select Општина, \
                  sum( iif( Тип_геотермалне_енергије = 
                                'Хидрогеотермална енергија', 1, 0 ) ) as [HGTE], \
                  sum( iif(  Тип_геотермалне_енергије = 
                                'Литогеотермална енергија', 1, 0 ) ) as [LGTE] \
                  from Објекат \
                  group by Општина; ";



When I type it in MS Access, it works well and outputs this ( code tags added for clearer look ):

C++
    |    Општина   |   HGTE   |   LGTE   | 
-----------------------------------------------
    |   Раковица   |      1   |     0    | 

    | Савски Венац |      1   |     0    |

    |    Сурчин    |      0   |     1    |

    | Стари Град   |      2   |     0    |


In my code, it fills the list view and the output looks like this:

C++
    |    Општина   |  HGTE    |  LGTE    | 
----------------------------------------------------
    |   Раковица   |      1   |     1    | 

    | Савски Венац |      1   |     0    |

    |    Сурчин    |      1   |     0    |

    | Стари Град   |      1   |     0    |


Details about the table, fields and columns :

C++
    |   Општина    | Тип_геотермалне_енергије  | ... other fields |  
------------------------------------------------------
    |  Стари Град  | Хидрогеотермална енергија |

    |    Сурчин    |  Литогеотермална енергија |

    |  Стари Град  | Хидрогеотермална енергија |

    | Савски Венац | Хидрогеотермална енергија |

    |   Раковица   | Хидрогеотермална енергија |


Why my query doesn't work in my code, when it works perfectly well in MS Access ?

Again, I work on Windows XP, in MS Visual Studio C++, using ADO to query MS Access 2007 database, and pure Win32 to display the result in list view.

Thanks.
Posted
Comments
Sergey Alexandrovich Kryukov 5-Aug-13 19:29pm    
Yee... Hydrothermal and geothermal energy supply is in jeopardy... :-)
Anyway, even if you screwed up somewhere, due to the current state of world lithosphere, my access to your hard drive is somewhat limited. :-)
—SA
MyOldAccount 5-Aug-13 19:34pm    
Hello again Sergey!

Browsing through Internet, I have found out that ADO might be the problem, since it doesn't support IIF().

Can you please help somehow?

If not for me, do it for the mother earth!
Sergey Alexandrovich Kryukov 5-Aug-13 19:37pm    
I would love it if I could...
I think the whole idea of using MS Access if very questionable. Totally proprietary, not even client-server based... Nah...
—SA
MyOldAccount 5-Aug-13 19:43pm    
Can you suggest another way ?

I have asked a question about it here Show count of columns distinct values[^].

It means a lot to me if you could help.

Me and mother earth are counting on you, old warrior, to save us! :))
Sergey Alexandrovich Kryukov 5-Aug-13 20:09pm    
Sorry, I almost don't do that database stuff... However, I would advise to switch to something reasonable. Review this:
http://en.wikipedia.org/wiki/List_of_relational_database_management_systems,
http://en.wikipedia.org/wiki/List_of_object_database_management_systems.

—SA

1 solution

Save your query directly in Access, then simply return the results of your query through ADO, rather than letting ADO try to do the work for you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900