473,698 Members | 1,877 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Checking DataSet value for null

How can I check this for null? dsPrsn.Tables(0 ).Rows(0)("WORK _STATE")
I tried If IsDbNull(dsPrsn .Tables(0).Rows (0)("WORK_STATE ")) Then it seems
not too work. I am attempting to check this field in my data set to see if
it is null or not. If it is null I want to set my drop down list to a
certain value (where I'm using dropdown.Select edValue = ). If it is not
null I want to set the drop down to the dataset value. Here is what the
login/code should be...

If IsDBNull(dsPrsn .Tables(0).Rows (0)("WORK_STATE ")) Then

cmbState.Select edValue = 'some value

Else

cmbState.Select edValue = dsPrsn.Tables(0 ).Rows(0)("WORK _STATE")

End If

THANKS!!!
Nov 19 '05 #1
2 1768
Andy, check out dbnull.value, e.g. vb syntax "if object is dbnull.value" - Bill

"Andy G" wrote:
How can I check this for null? dsPrsn.Tables(0 ).Rows(0)("WORK _STATE")
I tried If IsDbNull(dsPrsn .Tables(0).Rows (0)("WORK_STATE ")) Then it seems
not too work. I am attempting to check this field in my data set to see if
it is null or not. If it is null I want to set my drop down list to a
certain value (where I'm using dropdown.Select edValue = ). If it is not
null I want to set the drop down to the dataset value. Here is what the
login/code should be...

If IsDBNull(dsPrsn .Tables(0).Rows (0)("WORK_STATE ")) Then

cmbState.Select edValue = 'some value

Else

cmbState.Select edValue = dsPrsn.Tables(0 ).Rows(0)("WORK _STATE")

End If

THANKS!!!

Nov 19 '05 #2
Did you want to check for a null value instead? Null and DBNull are
technically different values. Try If ... Is Nothing to test for null.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Wed, 9 Feb 2005 14:40:48 -0600, "Andy G" <aj*****@iastat e.edu>
wrote:
How can I check this for null? dsPrsn.Tables(0 ).Rows(0)("WORK _STATE")
I tried If IsDbNull(dsPrsn .Tables(0).Rows (0)("WORK_STATE ")) Then it seems
not too work. I am attempting to check this field in my data set to see if
it is null or not. If it is null I want to set my drop down list to a
certain value (where I'm using dropdown.Select edValue = ). If it is not
null I want to set the drop down to the dataset value. Here is what the
login/code should be...

If IsDBNull(dsPrsn .Tables(0).Rows (0)("WORK_STATE ")) Then

cmbState.Selec tedValue = 'some value

Else

cmbState.Selec tedValue = dsPrsn.Tables(0 ).Rows(0)("WORK _STATE")

End If

THANKS!!!


Nov 19 '05 #3

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

Similar topics

5
7467
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 invented to make life easier, to be able to get to tge Tables and Values with less code, in less time? But with this thing you need to add a Try-Catch around every statement when using the value, add for each value a default value in your DataSet (and...
2
26689
by: Andreas Palm | last post by:
I have a dataset that has DBNull in certain columns, now when I write out this one to XML, I only get the columns as elements that do have data in it. However I do need also the empty colums as empty elements in the XML. How to do that ? I don't understand why there is no simple option to specify the output format, or did I miss something ? regards andreas
99
5147
by: Mikhail Teterin | last post by:
Hello! Consider the following simple accessor function: typedef struct { int i; char name; } MY_TYPE; const char *
8
2256
by: drg | last post by:
I have a DataSet with a DateTime field. I am using an EventRow r, to update it with values from a TextBox in a DataGrid. Suppose a DataGrid in edit mode had a field with value: 7/7/2005. Then the user deletes this value. Now, I want to update the DataSet (I know how to update the database) with a statement like this: r.MyDate = null. However, I can't seem to find the syntax to do this. Thanks!
1
1908
by: excelleinc.com | last post by:
Hi, I'm trying to check if field contains NULL value in MSSQl 2000 database but keep receiving error. asp.net code: If Trim(HLSQLDSet.Tables("mfglinks").Rows(15).Item(0)) Is Null Then URLSurgeS.Visible = "False" End If
4
2379
by: Patient Guy | last post by:
Does anyone have any coding rules they follow when doing argument checking? When arguments fail during check, do you return from the call with an ambiguous return value, or do you throw exceptions?
10
24175
by: mcbobin | last post by:
Hi, Here's hoping someone can help... I'm using a stored procedure to return a single row of data ie a DataRow e.g. public static DataRow GetManualDailySplits(string prmLocationID, string
13
2497
by: Karch | last post by:
I find myself doing things like this all the time: if ( SomeObject != null && SomeObject.AnotherObject != null && SomeObject.AnotherObject.YetAnother != null && SomeObject.AnotherObject.YetAnother.HelpMePlease != null) { // Do Something }
9
3276
by: GotDotNet? | last post by:
I have a dataset and I have to loop through it and some of the values for an insertition into the db. Some of the fields are integers and booleans but contain a NULL in the field. how can I check for a NULL and if its NULL insert DBNull into the db? Currently I'm getting error message System.DBNull.System.IConvertible.ToBoolean() now i need to get this field and insert a NULL into the db is the values
0
9155
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, 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...
0
9018
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8858
tracyyun
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...
0
7711
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, 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...
1
6517
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5859
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();...
0
4614
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3038
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
2
2322
muto222
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.