Home » U++ Library support » U++ SQL » fetch not reading into struct
fetch not reading into struct [message #32661] |
Wed, 01 June 2011 02:11  |
jjacksonRIAB
Messages: 227 Registered: June 2011
|
Experienced Member |
|
|
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?
|
|
|
Re: fetch not reading into struct [message #32664 is a reply to message #32661] |
Wed, 01 June 2011 08:34   |
|
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]
|
|
|
|
|
|
Goto Forum:
Current Time: Fri May 09 12:01:39 CEST 2025
Total time taken to generate the page: 0.00997 seconds
|