mictr


I am using MFC ODBC classes in my VC++ application for database accesss (on a SQL Server 2005 Database).
After opening a Recordset I have to use the CRecordset::GetFieldValue( LPCTSTR lpszName, CDBVariant& varValue, short nFieldType = DEFAULT_FIELD_TYPE ) method of the CRecordset object to obtain field values. The above method works fine with ODBC drivers for Jet but when I use ODBC for SQL Server it throws the following exception.

State:S1002,Native:0,Origin:[Microsoft][
ODBC SQL Server Driver] Invalid
Descriptor Index

I don't understand why the Microsoft SQL Server ODBC Driver is throwing this
exception.

Please help me!

Michael.



Re: ODBC Driver (for SQL Server 2005) unable to retrive CRecorset's fields values

JPA2002


I am having the same exact problem! Does anyone have any input

Jon






Re: ODBC Driver (for SQL Server 2005) unable to retrive CRecorset's fields values

GreenChocolate

Me too.






Re: ODBC Driver (for SQL Server 2005) unable to retrive CRecorset's fields values

GreenChocolate

I solved my problem. My situdation is: I use MFC wizard to generate the ODBC code and all the columns have been bound. I got the same error as your guys when I call GetFieldValue(). But since all columns have been bound, don't call GetFieldValue(), instead, directly access the member variable of the derived recordset class. Then problem disappeard.