Questions tagged [dbnull]

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

DBNull is a special value in the .Net framework indicating that the value is NULL in the database. It is required to disambiguate with .Net null, which basically means 'null pointer' or unallocated variable. Since it is a special value, it requires special handling to convert into other data types, check DB data for null values etc.

.Net uses System.DBNull singleton class to handle database values.

The DBNull class represents a nonexistent value. In a database, for example, a column in a row of a table might not contain any data whatsoever. That is, the column is considered to not exist at all instead of merely not having a value. A DBNull object represents the nonexistent column. Additionally, COM interop uses the DBNull class to distinguish between a VT_NULL variant, which indicates a nonexistent value, and a VT_EMPTY variant, which indicates an unspecified value.

In a relational database, null is used to describe a missing/unknown value, not to be confused with null (Nothing in ) - that's a reference that points nowhere.

322 questions
-2
votes
2 answers

How to convert a value if it's null

I am using C# Convert.ToDateTime(rdr["Termination_Date"]) rdr is defined as OracleDataReader rdr = cmd.ExecuteReader(); The Termination_Date field in the table maybe null. How do I check if it's null and set a date like 01/01/0001
software is fun
  • 7,286
  • 18
  • 71
  • 129
-3
votes
2 answers

DB Null conversion

I have written a relatively big insert statement, and some of the fields are null. I cannot convert from db null to other types and I don't really want to check Convert.IsDBNull for every single item What should I do? …
user1200540
-3
votes
1 answer

DBNull cast to (object) returns different value

I am trying to write DBNull.Value using Parameters.AddWithVallue when an optional parameter (a string) of a C# method is null. public static void Abc(string distrito, string municipio = null) command.Parameters.AddWithValue("@Municipio", municipio…
Dillinger
  • 341
  • 3
  • 16
-3
votes
1 answer

Unable to Handle Default Error Dialog for Dynamic DataGridView (Multiple NULL values)

WORK BRIEF: I have populated a DataGridView on button_click event. (Based on SQL query entered in the textbox, the DataGridView will be populated) private void button1_Click(object sender, EventArgs e) { string strSQLQuery =…
Bharath theorare
  • 524
  • 7
  • 27
-3
votes
2 answers

Show all null fields in a IEnumerable query

I have the following (easy) table: Table: MyDataTable **Color** Blue null Red Yellow null null Green This query (for example): query = from user in MyDataTable.AsEnumerable() where (user.Field("Color") != null ?…
karmany  
  • 39
  • 1
  • 6
-4
votes
3 answers

Inserting NULL value for a string variable in vb.net

I'm trying to insert a NULL value to a variable of type string. Please let me know the possible ways to do it. I googled about this problem and found that DBNul.value can be assigned to the particular variable that has to be inserted as NULL. When i…
Kals
  • 9
  • 1
  • 1
  • 3
-5
votes
3 answers

Ask about DBNULL to other types

hi am asking about my error see my screen shot, thanks DBNULL to other types I create my c# code to read a excel file but something had a problem see above my screen shot other problem , I inputted your code but will shown an error see screenshot…
J.Cloud
  • 11
  • 6
1 2 3
21
22