Why doesn't this work:
cbAutoBill.Chec ked = IIf(IsDBNull(re ader("autobill" )), False,
Convert.ToBoole an(reader("auto bill")))
Gives error: Object cannot be cast from DBNull to other types.
But this does:
cbAutoBill.Chec ked = IIf(IsDBNull(re ader("autobill" )), False,
reader("autobil l"))
"autobill" is a bit
-Max 2 2010
I could be wrong but I think that everything in the IIF statements gets
evaluated even if it is not used so that when reader("autobil l") is null the
convert is evaluated and fails even though you don't want that value to be
used. I could be wrong but I think I've had it explained to me that way.
Have you tried this:
cbAutoBill.Chec ked = Convert.ToBoole an(IIf(IsDBNull (reader("autobi ll")),
False, reader("autobil l")))
Paul Ross
Hebco, Inc.
"Max" <no****@notvali d.com> wrote in message
news:OM******** ******@TK2MSFTN GP15.phx.gbl... Why doesn't this work: cbAutoBill.Chec ked = IIf(IsDBNull(re ader("autobill" )), False, Convert.ToBoole an(reader("auto bill"))) Gives error: Object cannot be cast from DBNull to other types.
But this does: cbAutoBill.Chec ked = IIf(IsDBNull(re ader("autobill" )), False, reader("autobil l"))
"autobill" is a bit
-Max
Oh you know you're right. I totally get it now. IIF is just a function like
any other. It accepts 3 variables, which are *obviously* going to be
evaluated and THEN sent to the function! Duh!
-Max
"Pross" <ta******@aol.c om> wrote in message
news:u2******** ******@tk2msftn gp13.phx.gbl... I could be wrong but I think that everything in the IIF statements gets evaluated even if it is not used so that when reader("autobil l") is null the convert is evaluated and fails even though you don't want that value to be used. I could be wrong but I think I've had it explained to me that way. Have you tried this:
cbAutoBill.Chec ked = Convert.ToBoole an(IIf(IsDBNull (reader("autobi ll")), False, reader("autobil l")))
Paul Ross Hebco, Inc.
"Max" <no****@notvali d.com> wrote in message news:OM******** ******@TK2MSFTN GP15.phx.gbl... Why doesn't this work: cbAutoBill.Chec ked = IIf(IsDBNull(re ader("autobill" )), False, Convert.ToBoole an(reader("auto bill"))) Gives error: Object cannot be cast from DBNull to other types.
But this does: cbAutoBill.Chec ked = IIf(IsDBNull(re ader("autobill" )), False, reader("autobil l"))
"autobill" is a bit
-Max
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: ben3003 |
last post by:
I am only asking for my code to do a simple thing but for some reason i
just can't get it to do what i want it to do... it been bugging me all
day!
The user inputs 2 dates on one page. in the form xx/xx/xxxx
I then want the output page to display the amount of days that there
are between these two dates, inclusive. For example:
01/01/2005
03/01/2005
|
by: Alex |
last post by:
Hi,
an LPCTSTR is a long pointer to a const string. This is a
windows typicall variable type like UINT, DWORD and so on.
You can use it the same way like you would use standard
variable types in c++, i.g. char, bool or int.
To your second question. LPCWSTR is a long pointer to a
const Unicode string. The W in variable types stands for
Unicode. If you want to get more information on the
|
by: Rachel |
last post by:
My do while works the first time but the second time it breaks at the
len = Convert.ToDouble(Console.ReadLine());
It says that I have an unhandled System format exception. Help!
using System;
using System.Text;
namespace assignment1
{
|
by: Ghislain Tanguay |
last post by:
I have a compiled vb.net app and I want to give the user a choice to launch
it from the start line command and pass it a parameter or not. How can I do
that in my code? Is it possible?
Ex. : MyApp.exe "Go"
|
by: Jeff Calico |
last post by:
Hi
I have what I think is a easy question about how to pull cross
reference data
when I transform my XML file. I can't seem to find a good example of
how to do
this on the web, though.
Here is the XML file I am supposed to process:
| |
by: John |
last post by:
Is there any special code I have to write to log event to Security
Event Log? The following code give me "Very Easy Question, How to
write log to SECURTY Event Log? Please help" Error
// Create an EventLog instance and assign its source.
EventLog myLog = new EventLog();
myLog.Source = "Security";
// Write an informational entry to the event log.
myLog.WriteEntry("Writing warning to event log.",
|
by: robert.b.walden |
last post by:
Hello,
Easy question from a newbie. I have text boxes which collect users
input and on the click of a button do some calculations and output to
another text box. I need to easily convert the numbers inputted to
int's so I can do the calculations. Also I need to figure out how to
pop up an error box if the charactors entered in those boxes are
anything but numbers. Thanks in advance for helping someone trying to
learn this robust...
|
by: SteveM |
last post by:
I am sure this is an easy question, but being relatively new to ASP.NET
programming, I can not quite grasp what I need to accomplish what I
need to do.
What I have is a word document that is rendered as a page (or actualy a
part of a page) that is editiable. To do this I let the user download
the document, edit it and then upload it back to the site. Then at
Page_Open, I convert the .doc file to an html and render it back to the
page......
|
by: Aman JIANG |
last post by:
hi
I need to do this (convert double to string) fast, safe and
portable. Is there any way to do this ?
Except the ways following:
1. C++ I/O stream, stringstream (and boost::lexical_cast)
2. sprintf (and its brothers)
3. any nonstandard C/C++ functions
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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 we have to send another system
| | |