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
0
votes
0 answers

User can't delete DateTime in old Infragistics UltraGrid

I'm working on an older application now which uses Infragistics UltraGrid v3.1. In the UltraGrid the user can enter a date (with mask ____/____/_____). If there is already a date in the cell and the user wants to clear it, he'll get an error when he…
Gert Hermans
  • 769
  • 1
  • 9
  • 30
0
votes
1 answer

Best Way to Return non-"Nothing" Data from SQL Server to .NET Application

I commonly use the SqlDataAdapter class to retrieve data from SQL Server for consumption in a .NET application. Almost as commonly, while traversing the returned DataSet I often hit null object exceptions because the cell contains a DbBull which…
Chiramisu
  • 4,687
  • 7
  • 47
  • 77
0
votes
3 answers

Populating Object from DataTable with default value when DBNull

I am populating the customer object as shown below. How do I would I concisely code something like the following? If IsDbNull(.Age) Then .Age = 10 Else .Age = dataRow("Age") End If Here's the context I'd like to use it in: Public Shared…
kingkuber
0
votes
0 answers

LINQ vb.net Not IsDBNull

I have the following query that is supposed to filter out null values in the given groupfield but unfortunately returns an empty object when the source dataset contains null values in that field: Dim SelectQuery = From q1 In…
groobie
  • 1
  • 1
0
votes
2 answers

how do you set a defaultparametervalue of null for optional parameters?

So i have a chunk of code like this: public List GetSearchResultList(Search search, List listCatAttrib, string sortBy, int startRow, int pageSize, [Optional, DefaultParameterValue("")] string state,…
merk
  • 1,721
  • 5
  • 23
  • 39
0
votes
2 answers

How to handle all DBNulls without checking for them every time (with a generated DataSet)?

My original question was, as @nicholas correctly pointed, a little misleading, because this case is a little specific. So here's the real problem: I created Windows Form Application with DataGridView control and a DataSource generated from a table…
Harry
  • 4,524
  • 4
  • 42
  • 81
0
votes
1 answer

Oracle UDT (SdoGeometry) insert DBNull.Value fails

I am writing some sort of sync mechanism between a remote Oracle DB and a local Oracle XE DB using ODP.NET. The table i am syncing has a spatial column (and therefore a User Defined Type, sdo_geometry). My logic in C# does a select on the remote…
TurBas
  • 1,646
  • 13
  • 15
0
votes
3 answers

how to handled null exception in Db.SingleDecimal?

c = new TableCell(); decimal pembayaran = Db.SingleDecimal("Select (valuta) from ArInvoice where customerID='01'); c.Text = Cf.Num(pembayaran); c.Attributes["style"] = "text-align: right;"; tr.Cells.Add(c); it works when the query have a value, but…
Firma Agnes
  • 69
  • 1
  • 2
  • 8
0
votes
1 answer

Update many flag columns given the value of other columns (NULL values) in the same record

Given a table of input data I would like to have a set o "flag columns" that describe sibling columns of the same record. I am using Microsoft SQL Server 2005. First of all I need to load data in the target table, then I need to perform checks to…
TPPZ
  • 4,447
  • 10
  • 61
  • 106
-1
votes
1 answer

Clear to int value (DbNull.Value)

I want to change column value to DbNull.Value, I tried; stokIst.IstasyonId = DBNull.Value; stokIst not a primary key but its int column. I want to clear the value in the column as the target. When I save it at first, this value seems clear. an…
-1
votes
2 answers

How to convert DBNull into another type using C#?

I'm trying to write a code, which checks if a cell in selected row in DataGridView is empty/null before the cell will be updated with a value. The code, which I wrote, doesn't work, as I get an error: System.InvalidCastException: An object of type…
-1
votes
1 answer

Oracle.ManagedDataAccess.Client and add parameter with addwithvalue / DBNull

this i my query and parameter list i got msg "Not All Variable bound" Dim cmd As New OracleCommand("select POLICY_REFER, .... from POLICY_MASTER where ISSUE_DATE BETWEEN :DFrom AND :DTo And (CLIENT_NAME = :client…
-1
votes
2 answers

access sql-parameter with dbnull

I want to update some rows in my accessdatabase. When typing the whole query in the commandtext-object, everything works just fine. But when i try to use the parameters the DBNull-value doesn't get recognized: Here is how i do this: using (var…
Olli
  • 658
  • 5
  • 26
-1
votes
2 answers

How to ignore eror message "dbnull to string is not valid" and dont load empty cells to my vb form

When I click search button error occurs conversion dbnull to type string is not valid. I think there's no data in some cells in my database. its not a problem to have empty cells and if there are empty cells I don't want to load them to my…
-1
votes
1 answer

How to set the property to true that will allow me to insert null values?

I got the error in unit testing for the method of "AddEffectiveQuarterTest". How to set the property to true that will allow me to insert null values? AvailabilityBLTest.cs file : "AddEffectiveQuarterTest" method public void…
iop
  • 39
  • 1
  • 7
1 2 3
21
22