[Mono-list] Empty string saved as null in sql server

srf Scott.Fluto at cmgl.ca
Tue Jul 28 17:18:14 EDT 2009


I cant give you the exact ado .net commands since we use an Nhibernate Orm
but using its tracing , this is what its preparing:
INSERT INTO dbo.[EntityLabel] ([commitcount], [Saved], [Username],
[Comment], [IsSnapshot], [Name], [Created], [Description], Id) VALUES (@p0,
@p1, @p2, @p3, @p4, @p5, @p6, @p7, @p8); @p0 = '1', @p1 = '', @p2 =
'Default', @p3 = '', @p4 = 'False', @p5 = '', @p6 = '7/28/2009 9:11:29 AM',
@p7 = '', @p8 = '1c0a122a-1e26-4fc7-af5b-70c19f783188'

Note the p1 ,p3 and p5 values are empty strings. WHen I trace its using the
sqlserver profiler, the sql generated and being sent to the databaswe is
actually null values. When I try this on windows everything is the same
except that the empty strings remain as empty string.  I noticed that
everywhere when we insert empty strings they get inserted as nulls so it
seems to be common to everything. Do you have any thoughts on why this would
be happening. Is there some asumptions mono is taking to decide to set them
to null? As far as I know the only way it should is if I use the
System.Dbnull type

thanks

scott


Nagappan wrote:
> 
> Hello Scott,
> 
> Can you post a sample test to reproduce the issue you have mentioned here
> ?
> 
> Thanks
> Nagappan
> 
> On Tue, Jul 28, 2009 at 1:41 PM, srf <Scott.Fluto at cmgl.ca> wrote:
> 
>>
>> if I have a field that is an empty string rather than a null , when it
>> gets
>> saved it inserts a null rather than an empty string. With windows its
>> works
>> properly and stored an empty string. Has anyone else noticed this and had
>> problems storing an empty string rather than a null value into a
>> sqlserver
>> 2005 database or any other database?
>>
>> thanks
>>
>> scott
>> --
>> View this message in context:
>> http://www.nabble.com/Empty-string-saved-as-null-in-sql-server-tp24707463p24707463.html
>> Sent from the Mono - General mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> Mono-list maillist  -  Mono-list at lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-list
>>
> 
> 
> 
> -- 
> Linux Desktop (GUI Application) Testing Project -
> http://ldtp.freedesktop.org
> http://nagappanal.blogspot.com
> 
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
> 
> 

-- 
View this message in context: http://www.nabble.com/Empty-string-saved-as-null-in-sql-server-tp24707463p24708036.html
Sent from the Mono - General mailing list archive at Nabble.com.



More information about the Mono-list mailing list