Saturday, February 25, 2012

[Microsoft][ODBC SQL Server Driver] Invalid Descriptor Index

Hi,
I am using MFC ODBC classes in my VC++ application for database accesss (on
a SQL Server/Access Database).
Some times after opening a Recordset (containing bound columns generated
using the ClassWizard) 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!
SameerHi Sameer,
Thanks for posting in the community.
From your description, I understand that when you use the CRecordset::GetFie
ldValue
method t oobtain the field values after opening a binding columns recordset,
you will
receive the exception of Invalid Descriptor Index for ODBC SQL Server Driver
. However, the
problem doesn't occur with ODBC drivers for Jet.
Before we start, please notice that the issue is related to MFC programming
which is
gracefully handling in this queue. However, it's my pleasure to let me see i
f I can address
your problem and give some solutions. For quickly and efficiently solve your
problem, it's
better to post this issue in the corresponding queues such as ADO/VC/VC++ ne
wsgroup.
I'm not 100% sure why the exception was genereted when using ODBC SQL Server
Drivers.
Based on my research, per the ODBC docs SQLGetData throws that error if it's
called and
all the columns are already bound when it is generated using the ClassWizard
.
So the bottom line is that if you're using a CRecordset that was created wit
h
the AppWizard, don't use GetFieldValue. Instead, go to the record that you
want and then look at the data member of the recordset to get the field valu
e.
Please apply my suggestions above and let me know if this helps resolve your
problem. If
there is anything more I can do to assist you, please feel free to post it i
n the group.
If the problem still persists and you'd like to get the most qualified pool
of respondents,
please repost this issue to the corresponding queues I mentioned above. Addi
tionally,
other partners who read the newsgroups regularly can either share their know
ledge or learn
from your interaction with us. I hope the problem can be resolved quickly.
Best regards,
Billy Yao
Microsoft Online Support
----
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only. Thanks.

No comments:

Post a Comment