Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

BUG: ODBC Query of VFP View Returns SQL_NO_DATA_FOUND


View products that this article applies to.

This article was previously published under Q219025

↑ Back to the top


Symptoms

When using the ODBC Visual FoxPro (VFP) driver, a query to a Visual FoxPro view returns SQL_NO_DATA_FOUND from SQLExtendedFetch() and SQLFetch() as in the following code:

   sr = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, & hstmt );

   sr = SQLPrepare( hstmt, ( unsigned char * ) "select * from listview", SQL_NTS );

   // This call to SQLNumResultCols breaks the SQLExtendedFetch call.
   sr = SQLNumResultCols( hstmt, & colcount );

   sr = SQLExecute( hstmt );

   sr = SQLBindCol( hstmt, 1,  SQL_C_SLONG, & wineid, 4, & StrLen_or_Ind1 );

   sr = SQLBindCol( hstmt, 2, SQL_C_CHAR, winename, 51, & StrLen_or_Ind2 );

   // This returns 100 == SQL_NO_DATA_FOUND - but there is data!!!
   sr = SQLExtendedFetch( hstmt, SQL_FETCH_NEXT, 1, & RowCountPtr, & RowStatusArray );

   SQLFreeStmt( hstmt, SQL_DROP );

↑ Back to the top


Cause

Calling SQLNumResultCols(), SQLColAttributes(), and SQLDescribeCol() in between SQLPrepare() and SQLExecute() when querying a view, causes SQLExecute() to return an empty cursor on the view.

↑ Back to the top


Resolution

Use either of the following:

  • Do not call SQLNumResultCols(), SQLColAttributes(), or SQLDescribeCol() until after the call to SQLExecute().

    -or-

  • Call SQLExecDirect() and execute SQLNumResultCols(), SQLColAttributes(), SQLDescribeCol() following this call.

↑ Back to the top


Status

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

↑ Back to the top


Keywords: KB219025, kbpending, kbbug

↑ Back to the top

Article Info
Article ID : 219025
Revision : 3
Created on : 10/17/2003
Published on : 10/17/2003
Exists online : False
Views : 283