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 » U++ Library support » U++ SQL » fetch not reading into struct
Re: fetch not reading into struct [message #32664 is a reply to message #32661] Wed, 01 June 2011 08:34 Go to previous messageGo to previous message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

jjacksonRIAB wrote on Wed, 01 June 2011 03:11

I have a session created with MSSQL and am reading from a view in SQL server. My .sch file looks like this:

TABLE_ (PUNCH_VIEW)
	STRING_ (EMPLOYEE_ID, 6)
	STRING_ (FIRST_NAME, 15)
	STRING_ (LAST_NAME, 16)
END_TABLE


Now, when I create a session, I'm running over VPN so I have to impersonate first, then I create my connection and try to run a select:
S_PUNCH_VIEW view;

Sql sql(dbSession);
sql * Select(view).From(PUNCH_VIEW);

while(sql.Fetch(view))
{
    if(view.FIRST_NAME == "John")
    {
        // add this text to a GridCtrl
    }

    // Add data to GridCtrl
    grid.Add(sql);
}


For some reason the fetch is not filling S_PUNCH_VIEW "view" with any data. It's just empty through each cycle in the loop, but grid.Add(sql) actually works and displays the data.

Additionally if I try sql[FIRST_NAME] instead, I get an exception: "Assertion failed in Sql.cpp line 287 0". Any hints as to what I'm doing wrong?



Maybe you should try:
[code]
Sql sql(dbSession);
sql * Select(EMPLOYEE_ID, FIRST_NAME, LAST_NAME).From(PUNCH_VIEW);

while(sql.Fetch(view))
{
    if(view[FIRST_NAME] == "John")
    {
        // add this text to a GridCtrl
    }

    // Add data to GridCtrl
    grid.Add(sql);
}
[/code]

 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Creating a TIMESTAMP column in MySQL
Next Topic: Sqlite with U++
Goto Forum:
  


Current Time: Wed May 14 03:14:17 CEST 2025

Total time taken to generate the page: 0.00451 seconds