Top "Dbnull" questions

DBNull is a special value in The .Net framework indicating that the value is NULL in the database.

How to safely cast nullable result from sqlreader to int?

I have a table which contains null values and I need to get data from the table using SqlDataReader. I …

c# asp.net null sqldatareader dbnull
Cast a null into something?

I had this interesting discussion today with a colleague. We were debating two pieces of code in C#. Code Snippet 1: …

c# .net casting nullable dbnull
Vb.net Convert Integer DBNULL to 0 - error

I'm having this method: Private Function convertInteger(intInteger As Object) As Integer If IsDBNull(intInteger) Then convertInteger = 0 Else convertInteger = cInt(…

vb.net integer dbnull
How can I assign a DBNull in a better way?

I need to parse a value from a DataRow and assign it to another DataRow. If the input is valid, …

c# .net parsing datarow dbnull
What should I use to compare DBNull ? Using DBNull.Value or ToString().IsNullOrEmpty()

I can check for a DBnull on a data row using any of the methods. Either by using if(dr[0][0]==…

.net null dataset dbnull
Setting an empty string to null on Insert into database

I haven't been able to find the right solution for this issue, and I know it's so simple but I …

c# .net string sql-insert dbnull
Operator '??' cannot be applied to operands of type 'string' and 'System.DBNull'

I have the following C# code: sqlCommand.Parameters.AddWithValue("@Parameter", table.Value ?? DBNull.Value); But it throws the following compilation …

c# .net operators dbnull
Linq to DataTable - Cannot cast DBNull

New to Linq, so apologies if this is basic. This query is throwing up the error {"Cannot cast DBNull.Value …

c# linq casting dbnull
What is the point of DBNull?

In .NET there is the null reference, which is used everywhere to denote that an object reference is empty, and …

.net history dbnull rationale
Null safe way to get values from an IDataReader

(LocalVariable)ABC.string(Name)= (Idatareader)datareader.GetString(0); this name value is coming from database.. what happening here is if this …

c# extension-methods dbnull idatareader