ODBC catalog function call return error on sql server 2005



Hi,

I am having a problem for the ODBC catalog functions, the
server is sql server 2005 express beta2 and sql server 2005 beta2.

the code is as follows:

----------

RETCODE nRetCode;

AFX_SQL_ASYNC(this, SQLTables( m_hstmt,
(m_strQualifierParam.IsEmpty()? (UCHAR FAR *)NULL: (UCHAR FAR *)(const
char*) m_strQualifierParam),
SQL_NTS,
(m_strOwnerParam.IsEmpty()? (UCHAR FAR *)NULL: (UCHAR FAR *)(const
char*)m_strOwnerParam),
SQL_NTS,
(m_strTableNameParam.IsEmpty()? (UCHAR FAR *)NULL: (UCHAR FAR *)(const
char*)m_strTableNameParam),
SQL_NTS,
(m_strTableTypeParam.IsEmpty()? (UCHAR FAR *)NULL: (UCHAR FAR *)(const
char*)m_strTableTypeParam),
SQL_NTS ));


UCHAR sqlState[6]; /* buffer to store SQLSTATE */
SDWORD nativeErr; /* native error code */
UCHAR errMsg[100]; /* buffer to store error message */
SWORD realMsgLen; /* real length of error message */

if( nRetCode == SQL_ERROR )
{

RETCODE etcode1 = SQLError( SQL_NULL_HDBC,
SQL_NULL_HDBC, m_hstmt, sqlState, &nativeErr, errMsg,
100, &realMsgLen);
}

----------

the parameter values for my case:
m_strQualifierParam, m_strOwnerParam, m_strTableTypeParam
are all empty
m_strTableNameParam is "bl" which is a table in the
database for sure.


the error values are:
sqlstate:s0002
nativeerr:208
errMsg: "Invalid object name '#sptables'"


I also got errors for function call to "SQLForeignKeys"
with the errMsg as "Invalid object name '#spfkeys'",
and "SQLPrimaryKeys" with errMsg as "Invalid object
name '#sppkeys'". I guess all catalog functions do not
work.

I have tried both the SQL Server 2005 and 2005 express.

The same code and database file .mdf just work perfectly
for SQL Server 2000. For the ODBC data source, I have
tried both SQL Server and SQL Native Client.


I do appreciate your help.

Thanks.

Jing

.


Loading