• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 527
  • Last Modified:

MSSQL ODBC getfieldvalue throwing exception

When I access my Access database using ODBC and getfieldvalue in forward field index order or backward index order I have no problems.
When I try to access the same database converted to MSSQL using a variety of converters and simply point at the new ODBC connection, DBCORE.CPP throws an error "GetFieldValue operation failed on field" if I try to fietch a field using an index less than the last field fetched.

My code (simplified) is :

    CString cstrg;

    db.OpenEx(odbcname,0);
    rs.Open(CRecordset::dynaset,"SELECT * from DATAB");
    rs->GetFieldValue(5,cstrg);    \\Succeeds
    rs->GetFieldValue(7,cstrg);    \\Succeeds
    rs->GetFieldValue(4,cstrg);    \\ Fails

Is this a limitation of the MSSQL ODBC driver ?

To fetch in any other order is a real problems.

Any ideas ??

Peter
 

 
0
PSernz
Asked:
PSernz
1 Solution
 
Jaime OlivaresCommented:
First step I suggest you is to compare field type of Access and MSSQL table.
0
 
PSernzAuthor Commented:
Jaime,

Field types are not a problem.  These are text fields that can be viewed and changed in MS SQL using any of the query tools without a problem.  I can access all the fields ok if I access them in index order.  If I try to access a field with an index earlier than the last index I get the error.

Very strange.

Peter
0
 
AndyAinscowCommented:
Does it still fail if you try by name instead of by ordinal value?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
AndyAinscowCommented:
Is the field null?  (That should not be a problem with string values but...)
0
 
PSernzAuthor Commented:
Have not tried name fetch.  Can't imagine it will make a difference.
The fields carry text.  All of the fields fail if you fetch a field with index less than the last field fetched.
 
0
 
PSernzAuthor Commented:
I've found the problem.
SQLGetData (used by getfieldvalue) can not fetch columns in reverse order. Documented....
Sounds incredible but true.
This means that ODBC routines used toward Access will not work for MS SQL.
Thanks Microsoft...
0
 
moduloCommented:
PAQed with points refunded (500)

modulo
Community Support Moderator
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now