|
 |
ado_dotnet thread: DBNull ??
Message #1 by marl@s... on Fri, 21 Feb 2003 00:33:11
|
|
Hi:
I've got a line of code:
PrevPrice = (Single)row["Price"];
If row["Price"] contains a Null value it doesn't work because apparantly,
the Null won't transfer to the Single.
I've tried to figure out how to use DBNull but that doesn't work.
What should I do in the case where row["Price"] is null. I can't even find
a way to test for it.
HELP!
Message #2 by "Duncan" <duncan.faulkner1@b...> on Fri, 21 Feb 2003 09:53:23 -0000
|
|
Hi
The two options I can think are either have an IF...Then...End IF
statement Like
IF IsdbNull(row["Price"].value)then
PrevPrice=0
Else
Prevprice=row["Price"]
End if
Or
Prevprice = IIF(IsDBNull(row["Price"]),True:=0,False:=row["Price"]))
Duncan
-->-----Original Message-----
-->From: marl@s... [mailto:marl@s...]
-->Sent: 21 February 2003 00:33
-->To: ADO.NET
-->Subject: [ado_dotnet] DBNull ??
-->
-->
-->Hi:
-->
-->I've got a line of code:
-->PrevPrice = (Single)row["Price"];
-->
-->If row["Price"] contains a Null value it doesn't work
-->because apparantly,
-->the Null won't transfer to the Single.
-->
-->I've tried to figure out how to use DBNull but that doesn't work.
-->
-->What should I do in the case where row["Price"] is null. I
-->can't even find
-->a way to test for it.
-->
-->HELP!
-->===
-->Fast Track ADO.NET with C# is a concise introduction to the
-->concepts, techniques, and libraries that you will need in
-->order to start using ADO.NET in your applications. The book
-->covers DataSets and Typed DataSets, accessing data using
-->DataReaders and DataAdaptors, the close relationship between
-->ADO.NET and XML, how and where to use ADO.NET in your
-->enterprise applications, and how to use Web Services and
-->ADO.NET to easily pass data between applications.
-->http://www.wrox.com/books/1861007604.htm
-->---
-->Change your
-->mail options at
-->
-->
-->
Message #3 by "S. van Leeuwen" <s.van.leeuwen@k...> on Fri, 21 Feb 2003 11:12:06 +0100
|
|
if isdbnull(myrow("myfield"))
>-----Original Message-----
>From: marl@s... [mailto:marl@s...]
>Sent: Friday, February 21, 2003 12:33 AM
>To: ADO.NET
>Subject: [ado_dotnet] DBNull ??
>
>
>Hi:
>
>I've got a line of code:
>PrevPrice = (Single)row["Price"];
>
>If row["Price"] contains a Null value it doesn't work because apparantly,
>the Null won't transfer to the Single.
>
>I've tried to figure out how to use DBNull but that doesn't work.
>
>What should I do in the case where row["Price"] is null. I can't even find
>a way to test for it.
>
>HELP!
>===
>Fast Track ADO.NET with C# is a concise introduction to the
>concepts, techniques, and libraries that you will need in order to
>start using ADO.NET in your applications. The book covers DataSets
>and Typed DataSets, accessing data using DataReaders and
>DataAdaptors, the close relationship between ADO.NET and XML, how
>and where to use ADO.NET in your enterprise applications, and how
>to use Web Services and ADO.NET to easily pass data between applications.
>http://www.wrox.com/books/1861007604.htm
Message #4 by marl@s... on Fri, 21 Feb 2003 21:09:24
|
|
Thanks. That only works in VB though and I'm writing in C#.
Thanks anyway:)
> Hi
The two options I can think are either have an IF...Then...End IF
statement Like
IF IsdbNull(row["Price"].value)then
PrevPrice=0
Else
Prevprice=row["Price"]
End if
Or
Prevprice = IIF(IsDBNull(row["Price"]),True:=0,False:=row["Price"]))
Duncan
-->-----Original Message-----
-->From: marl@s... [mailto:marl@s...]
-->Sent: 21 February 2003 00:33
-->To: ADO.NET
-->Subject: [ado_dotnet] DBNull ??
-->
-->
-->Hi:
-->
-->I've got a line of code:
-->PrevPrice = (Single)row["Price"];
-->
-->If row["Price"] contains a Null value it doesn't work
-->because apparantly,
-->the Null won't transfer to the Single.
-->
-->I've tried to figure out how to use DBNull but that doesn't work.
-->
-->What should I do in the case where row["Price"] is null. I
-->can't even find
-->a way to test for it.
-->
-->HELP!
-->===
-->Fast Track ADO.NET with C# is a concise introduction to the
-->concepts, techniques, and libraries that you will need in
-->order to start using ADO.NET in your applications. The book
-->covers DataSets and Typed DataSets, accessing data using
-->DataReaders and DataAdaptors, the close relationship between
-->ADO.NET and XML, how and where to use ADO.NET in your
-->enterprise applications, and how to use Web Services and
-->ADO.NET to easily pass data between applications.
-->http://www.wrox.com/books/1861007604.htm
-->---
-->Change your
-->mail options at
-->
-->
-->
Message #5 by marl@s... on Fri, 21 Feb 2003 21:17:20
|
|
You're referring to VB??
I guess I didn't clarify that . .
I'm writing in C#. I finally came up with this:
if(myrow.IsNull("myfield"))
Thanks for the help:-)
> if isdbnull(myrow("myfield"))
>-----Original Message-----
>From: marl@s... [mailto:marl@s...]
>Sent: Friday, February 21, 2003 12:33 AM
>To: ADO.NET
>Subject: [ado_dotnet] DBNull ??
>
>
>Hi:
>
>I've got a line of code:
>PrevPrice = (Single)row["Price"];
>
>If row["Price"] contains a Null value it doesn't work because apparantly,
>the Null won't transfer to the Single.
>
>I've tried to figure out how to use DBNull but that doesn't work.
>
>What should I do in the case where row["Price"] is null. I can't even find
>a way to test for it.
>
>HELP!
>===
>Fast Track ADO.NET with C# is a concise introduction to the
>concepts, techniques, and libraries that you will need in order to
>start using ADO.NET in your applications. The book covers DataSets
>and Typed DataSets, accessing data using DataReaders and
>DataAdaptors, the close relationship between ADO.NET and XML, how
>and where to use ADO.NET in your enterprise applications, and how
>to use Web Services and ADO.NET to easily pass data between applications.
>http://www.wrox.com/books/1861007604.htm
|
|
 |