Showing posts with label recordset. Show all posts
Showing posts with label recordset. Show all posts

Wednesday, March 28, 2012

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

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.

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

Jon

|||Me too.|||

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.

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

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.

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

Jon

|||Me too.|||

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.

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

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.

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

Jon

|||Me too.

|||

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.

sql

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

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.

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

Jon

Wednesday, March 7, 2012

Obtaining data from an EXEC

Hi all,

I have a stored procedure which returns a recordset of data. What I want to do is execute this stored procedure in another stored procedure and insert the recordset returned into a temporary table.

ie.

Stored Procedure Test1 may perform the following action: -
SELECT * FROM MyTable1

Stored Procedure Test2 would do something like this: -

EXEC Test1

INSERT INTO #TempTable {The recordset returned from Test1}

Any ideas how I would go about this?

Cheers,

Robchange sp Test2 to:

insert into #TempTable
execute Test1|||Novice Brain Surgeon is an appropriate labal, you're a star.

Cheers,

Rob|||Actually, I hated the "Guru" label and was trying to be cute.