Logging NULLs to Database Target

2 messages Options
Embed this post
Permalink
tpaddock

Logging NULLs to Database Target

Reply Threaded More More options
Print post
Permalink
Hi!

I'm having a problem logging NULLs into a sqlserver database table. I am trying to insert null into an int column (which allows nulls).

I have tried using LogEventInfo.Context to set the value in c#:

    logEvent.Context[RUN_ID] = ...

And I use event-context layout in the config file for this parameter:

    <parameter name="@RunId" layout="${event-context:RunId}"/>

I've tried setting it to a null object, an uninitialized int, DBNull.Value, System.Data.SqlTypes.SqlInt32.Null, but none of these result in a Null being inserted into the database. They either result in the string "0", "", or "Null" (which throws an exception when trying to convert it to an int).

Everything works fine when inserting integers.

Any ideas about how to insert Nulls? Thanks - I appreciate it :)

-Todd

masdude

Re: Logging NULLs to Database Target

Reply Threaded More More options
Print post
Permalink
Did u find a solution to this problem? Theres hardly any documentation about it either.