all groups > sql server odbc > april 2005 >
You're in the

sql server odbc

group:

When does SQLPrepare validate table name


When does SQLPrepare validate table name CompWiz
4/12/2005 1:08:39 PM
sql server odbc:
In SQL2k if I call SQLPrepare with the following select statement:

SELECT * FROM sometable

where sometable doesnt exist, SQLPrepare doesnt return any error.
However I have had reports that this fails under SQL7. Should
SQLPrepare fail in this case? or is there some option that would need
to be turned on?

I am using version 2000.81.9031.38 of the sql server odbc driver.

Thanks
RE: When does SQLPrepare validate table name wread NO[at]SPAM online.microsoft.com
4/20/2005 9:56:24 PM
One of the SQL 8.0 enhancements was to automatically defer Preparing a
statement until either the metadata was requested or a SQLExecute is called.

To restore your application to expect SQL 7.0 behavior of getting an error
at SQLPrepare time you'll need to call:

SQLSetStmtAttr(hstmt, SQL_SOPT_SS_DEFER_PREPARE, (SQLPOINTER)SQL_DP_OFF,
SQL_IS_UINTEGER)

To switch back to SQL 8.0 behavior (the default), call:

SQLSetStmtAttr(hstmt, SQL_SOPT_SS_DEFER_PREPARE, (SQLPOINTER)SQL_DP_ON,
SQL_IS_UINTEGER)

~Warren

AddThis Social Bookmark Button