473,396 Members | 2,004 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,396 software developers and data experts.

Does field exist???

Is there anyway to check a dataset to see if a field exists?
foreach(DataRow row in ds.Tables[0].Rows)
{
if(row["fldname1"].ToString() == null) ******************This does not
work???????????????????????
{
cbFields.Items.Add (new ListItem(row["fldname"].ToString(),
row["fldtext"].ToString()));
}
else
{
cbFields.Items.Add (new ListItem(row["fldname"].ToString(),
row["fldtext"].ToString()));
}
}
--
David Fetrow
Helixpoint LLC.
http://www.helixpoint.com
da***@helixpoint.com
Nov 19 '05 #1
2 1290
There are two separate questions:
Q1. Does a field exists?
A1. row.Table.Columns.Contains("fldname")

Q2. Is the field value null?
A2. row.IsNull("fldname")

Eliyahu

"DaveF" <df*****@geodecisions.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Is there anyway to check a dataset to see if a field exists?
foreach(DataRow row in ds.Tables[0].Rows)
{
if(row["fldname1"].ToString() == null) ******************This does not
work???????????????????????
{
cbFields.Items.Add (new ListItem(row["fldname"].ToString(),
row["fldtext"].ToString()));
}
else
{
cbFields.Items.Add (new ListItem(row["fldname"].ToString(),
row["fldtext"].ToString()));
}
}
--
David Fetrow
Helixpoint LLC.
http://www.helixpoint.com
da***@helixpoint.com

Nov 19 '05 #2
You can also check the column .Value to DBNull.

if ( row["field1"] == DBNull.Value )
//the column is null.

bill

"DaveF" <df*****@geodecisions.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Is there anyway to check a dataset to see if a field exists?
foreach(DataRow row in ds.Tables[0].Rows)
{
if(row["fldname1"].ToString() == null) ******************This does not
work???????????????????????
{
cbFields.Items.Add (new ListItem(row["fldname"].ToString(),
row["fldtext"].ToString()));
}
else
{
cbFields.Items.Add (new ListItem(row["fldname"].ToString(),
row["fldtext"].ToString()));
}
}
--
David Fetrow
Helixpoint LLC.
http://www.helixpoint.com
da***@helixpoint.com

Nov 19 '05 #3

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

Similar topics

12
by: Fred Pacquier | last post by:
First off, sorry for this message-in-a-bottle-like post... I haven't been able to phrase my questions well enough to get a meaningful answer from Google in my research. OTOH, it is standard...
20
by: | last post by:
If I need to check if a certain value does exist in a field, and return either "yes" or "not" which query would be the most effestive?
3
by: Roger | last post by:
How can I check if a field already exist in a table? If it doesn't exist I want to add it with ALTER TABLE ADD...
0
by: Dirk Försterling | last post by:
Hi all, a few days ago, I upgraded from PostgreSQL 7.2.1 to 7.4, following the instructions in the INSTALL file, including dump and restore. All this worked fine without any error (message). ...
13
by: MLH | last post by:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer) If LaborCost > 0 Then Me!LaborCost.Visible = True If MatlsCost > 0 Then Me!MatlsCost.Visible = True If OtherCost > 0 Then...
16
by: lawrence k | last post by:
I've a file upload script on my site. I just now used it to upload a small text document (10k). Everything worked fine. Then I tried to upload a 5.3 meg Quicktime video. Didn't work. I've...
3
by: Michael | last post by:
Hi, I am getting a strange error. Last night when I left work this was working perfectly. This morning when I try to run this code in VS2005, it comes up with an error saying "The name 'UserName'...
1
by: Agnes | last post by:
pKcno = myReader.Item("kcno") <--it will return error when the field "kcno" doesn't exist any method to check the field exist or not first , if not exist, I want to skip the above statement. ...
32
by: Stephen Horne | last post by:
I've been using Visual C++ 2003 for some time, and recently started working on making my code compile in GCC and MinGW. I hit on lots of unexpected problems which boil down to the same template...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
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...

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.