Hi everybody,
I have this:
[code]
Dim IJavaValue As String = "" '= System.DBNull.Value.ToString()
If String.IsNullOrEmpty(IJavaValue.ToString().Trim) = True Then
IJavaValue = DBNull.Value
End If
[/code]
Then I get the message: Error 43 Value of type 'System.DBNull' cannot be converted to 'String'
And if I try this: IJavaValue = DBNull.Value.ToString()
But then If I look in the Databse I see an empty column and not the value 'NULL' in the column
Thank you
VulpesPosted Apr 23, 2014, 6:08 AM
If it's a nullable column, it will then be set automatically to null.
VulpesPosted Apr 23, 2014, 6:42 AM
As the Value property is of Object type you can set it to DBNull.Value without falling foul of any type conversion rules.
If it's a string column, then using DBNull.Value.ToString() won't work as this just produces an empty string.
Jignesh TrivediPosted Apr 23, 2014, 6:24 AM
Agree with Vulpes.
Are you tried below code?
IJavaValue = null; (this is C# syntax)