Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Save an empty string (not null) with ODBC

13 views
Skip to first unread message

Vicente Flich

unread,
Nov 20, 2009, 1:24:01 PM11/20/09
to
I have an application developed in Visual C++ than write to a SQL Server 2005
database. We need to write empty string (zero length string, not null) values
to fields of varchar type.

When we write trough odbc SQL Native Client driver and empty string, the
odbc write a NULL value.

I search in internet for this problem and see than this is because odbc can
not differentiate the NULL value from an emty string.

They are any option to change this behavior of odbc native client driver?

We try to connect usig a system DSN and so a connection string, but the
problem is always.

The connection string we use is:

"DRIVER={SQL Native Client}; SERVER=servidor; Trusted_Connection=YES;
DATABASE=prueba;MARS_Connection=yes;"

Thank you

John Elliot

unread,
Nov 25, 2009, 5:32:37 PM11/25/09
to
I am pretty sure ODBC can differentiate between NULL and empty strings.
Try using a third party tool that uses ODBC like WinSQL to confirm.

How are you writing your query? Try the following:

UPDATE YourTable
SET ColumnName = ''
WHERE ...

0 new messages