dbaspot
Tags Register FAQ Calendar Search Today's Posts Mark Forums Read

SQL 2008 Driver not returning SQL_NULL_DATA for null values. - sqlserver-odbc

This is a discussion on SQL 2008 Driver not returning SQL_NULL_DATA for null values. - sqlserver-odbc ; I have this ODBC code that runs fine with SQL 2005 Native Driver connected to a SQL 2005 database. The same code gives me a different result when I use the SQL 2008 Native Driver connected to a SQL 2008 ...


Home > Database Forum > Microsoft SQL Server > sqlserver-odbc > SQL 2008 Driver not returning SQL_NULL_DATA for null values.

Reply

 

LinkBack Thread Tools Display Modes
  #1  
Old 10-30-2008, 02:12 PM
Database Bot
 
Join Date: Sep 2009
Posts: 1,236,254
Database Administrator is on a distinguished road
Default SQL 2008 Driver not returning SQL_NULL_DATA for null values.

I have this ODBC code that runs fine with SQL 2005 Native Driver connected to
a SQL 2005 database. The same code gives me a different result when I use the
SQL 2008 Native Driver connected to a SQL 2008 database (or for that matter
the problem happens even for SQL 2008 Native Driver connected to SQL 2005
database). So, the problem seems to be with the SQL 2008 Native Driver.

My stripped down version of the ODBC code is as shown below:


long lPtr = 0;
SQLBindCol(myQuery, 1, SQL_C_LONG, &myId, 0, &lPtr);
SQLFetch(myQuery);
if (lPtr == SQL_NULL_DATA)
{

}
else
{

}


For this particular column, the value that is stored in the database is NULL
and that I have verified using the SQL 2008 Management Studio.

When the app is run using SQL 2005 Driver, the variable "lPtr" contains
SQL_NULL_DATA (which is defined as -1 in the SQL.H file)
When the app is run using SQL 2008 Driver, the variable "lPtr" contains 0
(which is the value for SQL_SUCCESS in the SQL.H file)

Now, is this a problem with SQL 2008 Native Driver? Is there some setting or
some parameter that can give me the same result in 2008 as I get in 2005? Or
have I unwittingly stumbled into a SQL 2008 bug?

Thanks.
Reply With Quote
Reply

Thread Tools
Display Modes



All times are GMT -4. The time now is 07:07 PM.