473,408 Members | 1,728 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

parameterized sql...dbnull value?

I should know this, but I don't...

How do I enter a null value in an integer field using parameterized SQL?

I have this:

Dim bonding2ID As Integer
If cleanSQLinput(DropDownList_bondingCo2.SelectedItem .Value.ToString) =
"none" Then
bonding2ID = DBNull.Value
Else
bonding2ID =
cleanSQLinput(DropDownList_bondingCo2.SelectedItem .Value.ToString)
End If

But it's not liking the 'DBNull.Value' part.

-Darrel

================================================== ===============
Win prizes searching google:
http://www.blingo.com/friends?ref=hM...nTqhv-2GE1FNtA
Jul 3 '06 #1
5 1730
Hi,
I think u r corret.

Try System.DbNull.Value to store a NULL value.
Regards,
Bharti Kumar.
darrel wrote:
I should know this, but I don't...

How do I enter a null value in an integer field using parameterized SQL?

I have this:

Dim bonding2ID As Integer
If cleanSQLinput(DropDownList_bondingCo2.SelectedItem .Value.ToString) =
"none" Then
bonding2ID = DBNull.Value
Else
bonding2ID =
cleanSQLinput(DropDownList_bondingCo2.SelectedItem .Value.ToString)
End If

But it's not liking the 'DBNull.Value' part.

-Darrel

================================================== ===============
Win prizes searching google:
http://www.blingo.com/friends?ref=hM...nTqhv-2GE1FNtA
Jul 4 '06 #2
There's no easy way...you can use a nullable type in 2.0, but that only gets
you 1/2 way there anyways.

Write it as a method that returns an object *shrug*

function GetBondId() as object
if BLAH
return DBNull.Value
end if
return cleanSQLinput(BLAHx)
end function

Karl

--
http://www.openmymind.net/

"darrel" <no*****@nowhere.comwrote in message
news:ef**************@TK2MSFTNGP04.phx.gbl...
>I should know this, but I don't...

How do I enter a null value in an integer field using parameterized SQL?

I have this:

Dim bonding2ID As Integer
If cleanSQLinput(DropDownList_bondingCo2.SelectedItem .Value.ToString) =
"none" Then
bonding2ID = DBNull.Value
Else
bonding2ID =
cleanSQLinput(DropDownList_bondingCo2.SelectedItem .Value.ToString)
End If

But it's not liking the 'DBNull.Value' part.

-Darrel

================================================== ===============
Win prizes searching google:
http://www.blingo.com/friends?ref=hM...nTqhv-2GE1FNtA

Jul 4 '06 #3
his problem is assigning DBNull.Value to an integer...which you can't.

Karl

--
http://www.openmymind.net/

"Bharathi Kumar" <bh************@gmail.comwrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...
Hi,
I think u r corret.

Try System.DbNull.Value to store a NULL value.
Regards,
Bharti Kumar.
darrel wrote:
>I should know this, but I don't...

How do I enter a null value in an integer field using parameterized SQL?

I have this:

Dim bonding2ID As Integer
If cleanSQLinput(DropDownList_bondingCo2.SelectedItem .Value.ToString) =
"none" Then
bonding2ID = DBNull.Value
Else
bonding2ID =
cleanSQLinput(DropDownList_bondingCo2.SelectedIte m.Value.ToString)
End If

But it's not liking the 'DBNull.Value' part.

-Darrel

================================================= ================
Win prizes searching google:
http://www.blingo.com/friends?ref=hM...nTqhv-2GE1FNtA

Jul 4 '06 #4
There's no easy way...

Damn.
function GetBondId() as object
if BLAH
return DBNull.Value
end if
return cleanSQLinput(BLAHx)
end function
So, I'm basically just returning two different types of objects? I'll give
that a shot.

Out of curiosity, what kind of object DOES accept null values?

-Darrel
Jul 5 '06 #5
System.Object is the only one I know about. Even Nullable types in 2.0 don't
natively support a database's NULL value (which makes this pretty useless)

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"darrel" <no*****@nowhere.comwrote in message
news:um**************@TK2MSFTNGP02.phx.gbl...
>There's no easy way...

Damn.
>function GetBondId() as object
if BLAH
return DBNull.Value
end if
return cleanSQLinput(BLAHx)
end function

So, I'm basically just returning two different types of objects? I'll give
that a shot.

Out of curiosity, what kind of object DOES accept null values?

-Darrel

Jul 5 '06 #6

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...
11
by: Patrick.O.Ige | last post by:
When i try and use this (Where Unit is a column in my Table):- If Unit Is DBNull.Value Then Return "1" Else Return "2" End If I always have 2 returned! Even when Unit is NULL! I want a...
4
by: Dursun | last post by:
Hi, I am trying to assign NULL to a datetime field in the SQL Server database. Here is the code that does NOT work: INSERT INTO ... .... VALUES ... .... CType(IIf(dateWitness2Date.Checked,...
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...
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,...
6
by: Charlie Brown | last post by:
When checking for NULL values from a database, normally I would use If Not row("NetSales") Is DBNull.Value Then NetSales = row("NetSales") End If However, if I use a typed dataset then I...
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
3
by: xlar54 | last post by:
I am writing a parametrized query, where Im building an UPDATE statement through concatenation, and then adding the parameters such as: UPDATE myTable SET = @newcolumna, = @newcolumnb WHERE ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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,...
0
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...

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.