473,473 Members | 1,549 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Help with DBNUll

Hello:

When I try to do the following,
Dim liTemp As System.DBNull
If c.Value Is Nothing Then
newDataTableRow(c.Column.Key) = liTemp
Else
newDataTableRow(c.Column.Key) = c.Value
End If
I get the exception:

Exception Details: System.ArgumentException: Cannot set Column 'D_STAT_DT'
to be null. Please use DBNull instead.

Am I not doing that?

Venki

Nov 21 '05 #1
6 4693
Try using DbNull.Value
"vvenk" <vv***@discussions.microsoft.com> wrote in message
news:C3**********************************@microsof t.com...
Hello:

When I try to do the following,
Dim liTemp As System.DBNull
If c.Value Is Nothing Then
newDataTableRow(c.Column.Key) = liTemp
Else
newDataTableRow(c.Column.Key) = c.Value
End If
I get the exception:

Exception Details: System.ArgumentException: Cannot set Column 'D_STAT_DT'
to be null. Please use DBNull instead.

Am I not doing that?

Venki

Nov 21 '05 #2
Hi,

"vvenk" <vv***@discussions.microsoft.com> wrote in message
news:C3**********************************@microsof t.com...
Hello:

When I try to do the following,
Dim liTemp As System.DBNull
If c.Value Is Nothing Then
newDataTableRow(c.Column.Key) = liTemp
Else
newDataTableRow(c.Column.Key) = c.Value
End If
I get the exception:
Try using DBNull.Value, eg:

If c.Value Is Nothing Then
newDataTableRow(c.Column.Key) = DBNull.Value
Else
newDataTableRow(c.Column.Key) = c.Value
End If

hth,
Greetings

Exception Details: System.ArgumentException: Cannot set Column 'D_STAT_DT'
to be null. Please use DBNull instead.

Am I not doing that?

Venki

Nov 21 '05 #3
"vvenk" <vv***@discussions.microsoft.com> schrieb:
When I try to do the following,
Dim liTemp As System.DBNull
If c.Value Is Nothing Then
newDataTableRow(c.Column.Key) = liTemp
Replace the line above with '...(...) = DBNull.Value'. 'DBNull' is a type
and thus cannot be assigned to the variable.
Else
newDataTableRow(c.Column.Key) = c.Value
End If
I get the exception:

Exception Details: System.ArgumentException: Cannot set Column 'D_STAT_DT'
to be null. Please use DBNull instead.


--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #4
VVenk,

You have not instanced your
Dim liTemp As System.DBNull


Probably
Dim liTemp As System.DbNull = Nothing

Will give you the result you want.

However I use direct dbnull.Value

I hope this helps,

Cor
Nov 21 '05 #5
Cor,

"Cor Ligthert [MVP]" <no************@planet.nl> schrieb:
You have not instanced your
Dim liTemp As System.DBNull


Probably
Dim liTemp As System.DbNull = Nothing


I assume you wanted to write '... As DBNull = DBNull.Value'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Nov 21 '05 #6
Herfried,

I saw everybody giving the same answers as Bill did.

Therefore I thought I do the same, however you know if I do that, it has to
be an addition or something else.

I was thinking on your option, however the one I gave did look for me even
more different.

Therefore I tested it before and had the idea that it was working.

:-)

Cor
Nov 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: DraguVaso | last post by:
Hi, Something I don't understand about a Typed DataSet: When a value in the DataSet is DBNull, it throws this error: "Cannot get value because it is DBNull". But aren't Typed DataSets...
4
by: Tina | last post by:
I have instantiated an insertRow for a dataset. I now want to make the GLCode DBNull. I have tried: insertRow.GLCode = Convert.dbnull insertRow.GLCode = Convert.dbnull(insertRow.GLCode) and...
8
by: MattB | last post by:
Hello. I have a vb.net (asp.net) application that uses ado.net datasets. At one point, I need to check a text field in a DataTable to see if there's any text in it before performing text operations...
10
by: Bob | last post by:
I'm sure there's a good reason, I just haven't been able to think of it - why didn't MS allow "DBNull" values to simply be a null (Nothing)? Bob
6
by: tshad | last post by:
I have a value coming from my Object (or it could also be from a SqlDbReader) where I need to test for DBNull and 0. I tried to do it in one call: if (not (newPosition.ReportsTo is...
2
by: Julian | last post by:
I have the following code: Dim strQuery As String = "SELECT tblData.CoPayFundGrant, tblData.M_DSS_SSA_Benefits, tblData.O_DSS_SSA_Benefits, " & _ "tblData.Ref_MPS, tblData.Ref_LA,...
19
by: Dave | last post by:
If Iwant to check if dataset1.SelectQuery1.column1 == System.DBNull.Value. How do I do this? What I wrote above will give an error. -- L. A. Jones
2
by: =?Utf-8?B?UHVjY2E=?= | last post by:
I'm getting the following Errors during run time and I tried capturing it using the code below but I'm not able to. I'm also showing in Debug the value is {}. How can I catch this so it won't...
3
by: DragonLord | last post by:
Here is the situation I am inserting rows into a datagridview and then using a function to group similar rows together based on a column. When I call to compare the lastrow with the current row...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.