473,772 Members | 2,478 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Loading a dataset with XML that contains empty values

I am working on a project where I get a XML datastream back from an
application API which may contain a particular value that may be
emty. An example of this can be seen below

<?xml version="1.0" encoding="iso-8859-1" ?>
- <NamedProfileLi st>
- <NamedProfile >
<ProfileID>1152 80</ProfileID>
<Name>Generatio n|Aks G7|16316</Name>
<Type>Meter</Type>
<StartTime>20 07-06-21T00:00:00</StartTime>
<StopTime>200 7-06-21T01:00:00</StopTime>
<Value>0.000</Value>
</NamedProfile>
- <NamedProfile >
<ProfileID>1152 80</ProfileID>
<Name>Generatio n|Aks G7|16316</Name>
<Type>Meter</Type>
<StartTime>20 07-06-21T01:00:00</StartTime>
<StopTime>200 7-06-21T02:00:00</StopTime>
<Value />
</NamedProfile>
....
....
When loading the XML this value causes the dataset to throw an
exception because there is a NULL value there. My question is is
there a way to keep this NULL value from throwing an exception on the
load of the dataset? I have searched the web over for an answer and
have not found one. Thanks for any help offered.

James

Jun 22 '07 #1
2 1872
Hi !

You have to configure the columns of the table belonging to dataset to
accepts NULL values

Regards,
Mihai

"TexasAggie 96" <jr*********@ms n.comwrote in message
news:11******** ************@m3 6g2000hse.googl egroups.com...
I am working on a project where I get a XML datastream back from an
application API which may contain a particular value that may be
emty. An example of this can be seen below

<?xml version="1.0" encoding="iso-8859-1" ?>
- <NamedProfileLi st>
- <NamedProfile >
<ProfileID>1152 80</ProfileID>
<Name>Generatio n|Aks G7|16316</Name>
<Type>Meter</Type>
<StartTime>20 07-06-21T00:00:00</StartTime>
<StopTime>200 7-06-21T01:00:00</StopTime>
<Value>0.000</Value>
</NamedProfile>
- <NamedProfile >
<ProfileID>1152 80</ProfileID>
<Name>Generatio n|Aks G7|16316</Name>
<Type>Meter</Type>
<StartTime>20 07-06-21T01:00:00</StartTime>
<StopTime>200 7-06-21T02:00:00</StopTime>
<Value />
</NamedProfile>
....
....
When loading the XML this value causes the dataset to throw an
exception because there is a NULL value there. My question is is
there a way to keep this NULL value from throwing an exception on the
load of the dataset? I have searched the web over for an answer and
have not found one. Thanks for any help offered.

James

Jun 22 '07 #2
On Jun 22, 11:57 am, "Mihai" <bvel...@telus. netwrote:
Hi !

You have to configure the columns of the table belonging to dataset to
accepts NULL values

Regards,
Mihai

"TexasAggie 96" <jrwallac...@ms n.comwrote in message

news:11******** ************@m3 6g2000hse.googl egroups.com...
I am working on a project where I get a XML datastream back from an
application API which may contain a particular value that may be
emty. An example of this can be seen below
<?xml version="1.0" encoding="iso-8859-1" ?>
- <NamedProfileLi st>
- <NamedProfile >
<ProfileID>1152 80</ProfileID>
<Name>Generatio n|Aks G7|16316</Name>
<Type>Meter</Type>
<StartTime>20 07-06-21T00:00:00</StartTime>
<StopTime>200 7-06-21T01:00:00</StopTime>
<Value>0.000</Value>
</NamedProfile>
- <NamedProfile >
<ProfileID>1152 80</ProfileID>
<Name>Generatio n|Aks G7|16316</Name>
<Type>Meter</Type>
<StartTime>20 07-06-21T01:00:00</StartTime>
<StopTime>200 7-06-21T02:00:00</StopTime>
<Value />
</NamedProfile>
....
....
When loading the XML this value causes the dataset to throw an
exception because there is a NULL value there. My question is is
there a way to keep this NULL value from throwing an exception on the
load of the dataset? I have searched the web over for an answer and
have not found one. Thanks for any help offered.
James- Hide quoted text -

- Show quoted text -
Sorry about that... I should have said in the first post. The column
is a double and here are all of the properties for the column.
AllowDBNull = True
AutoIncrement = False
AutoIncrementSe ed = 0
AutoIncrementSt op = 1
Caption = Value
DataType = System.Double
DateTimeMode = UnspecifiedLoca l
DefaultValue = 0
MaxLength = -1
NullValue = (Throw Exception)
ReadOnly = False
Unique = False
Name = Value

I try to change the NullValue parameter but this is disagreeable with
the class, just states that throw expection is the only value that can
be chosen. It would be nice to be able to load this data and have the
empty values default to zero.

Jun 22 '07 #3

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

Similar topics

2
26710
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
1
2002
by: John | last post by:
Hi All, When I delete the last record from my dataset and then WriteXML() to the file; the Table itself, in the xml file, is removed. I need to prevent the table structure from being deleted if there are no more records to be written to the XML file from the Dataset. Any ideas here, John.
5
3703
by: Jason | last post by:
I am having problems understanding how to access a datasource only once, fill a single dataset, and then reference that dataset multiple times through different user controls(ascx) found on the same page. My main page(aspx) contains multiple user controls. The main page also contains a publicly declared dataset. At the first instance of needing data I call (from an ascx) a function that fills the dataset and then returns it to the...
3
1741
by: martin | last post by:
Hi, I am having trouble determining if my dataset is empty. I have function that populates a dataset from a database and then retuens it. If the database contains no data then the dataset will be completely empty, and then when I go to databind() it to a combo box and error will be throw. What I whould like to do is check the dataset from code to see if it is empty.
5
7428
by: Roy Lawson | last post by:
I am having no problems connecting to a DB, creating a DataAdapter, and creating a dataset...and connecting to the data. Using the builtin data objects to do all this. My only problem now is navigating through the data. I can get the data into a datagrid without any problems, but I want the data to show up in textboxes and use some sort of move next, move previous, move last, etc (like in VB6) command to navigate the data (using...
22
4235
by: EMW | last post by:
Hi, I managed to create a SQL server database and a table in it. The table is empty and that brings me to my next chalenge: How can I get the info in the table in the dataset to go in an empty SQL table? Is there a short way like the FILL method to get data into the dataset or do I have to read each datarow in the table and write it one at the time to the
4
2253
by: Al | last post by:
I have this scenario: 1. XML file with schema and data is created from SQL Server tables. XML file contains 6 tables, some of them have rows, some of them are empty. 2. XML file is given to the person with Pocket PC. 3. XML file is used to populate DataSet on the Pocket PC. 4. User adds new rows, changes values, deletes some rows. 5. Altered dataset is saved back to XML file. 6. XML file is given back to the person who initially created...
6
5069
by: cmorgan76 | last post by:
This is a 2 part question: Part 1: I am accesing a web service that returns an xml string of user information. I am attempting to load the XML into an XMLDocument, save the document, load it into a dataset, and bind the dataset to a gridview. I'm not sure if it's neccesary to save the XML file to disk, but I wanted to make sure it was well formed. It is. No exceptions are caught during the loading and binding process, but my gridview...
20
4304
by: Nickolai Leschov | last post by:
Hello all, I am programming an embedded controller that has a 'C' library for using its system functions (I/O, timers, all the specific devices). The supplied library has .LIB and .H files. How can I dynamically load a LIB file and access all its functions? Surely someone has solved similar task? My intention is to use a Forth system for programming the controller,
0
9454
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,...
0
10264
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
10106
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...
1
10039
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,...
0
9914
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...
1
7461
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
6716
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();...
1
4009
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
3610
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.