?
Solved

Get exception in my dataset when reading a xml-schema with empty fields

Posted on 2005-02-25
6
Medium Priority
?
313 Views
Last Modified: 2010-04-16
Hi,

I call a web service, the result is a xml (dataset).

The xml contains empty fields and I want my dataset to replace the empty fields with default values. This doesn't work and when I try to reach the fields I get a exception. The field has no value.

I want the dataset to set defaultvalues for empty fields.
0
Comment
Question by:TYB
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 1

Expert Comment

by:Munti
ID: 13401753
what is the exception?
0
 

Author Comment

by:TYB
ID: 13402260
An unhandled exception of type 'System.Data.StrongTypingException
0
 
LVL 1

Expert Comment

by:Munti
ID: 13402324
How do you work with the data? Do you load it into a dataset? If then there really should be no problem in looping through the datatables rows and check for null value in each column.

foreach(DataRow row in ds.Tables["tablename"/index].Rows)
{
for(int i=0;i<row.items.length;i++)
{
if(row[i].ToString() == "")
row[i] = "put your value here...";
}
}
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:TYB
ID: 13402763
The web service return the dataset as return value.

MyWebservice myService = new MyWebservice();

DataSet dSet = new DataSet();

dSet = myWebService().GetAll();
0
 
LVL 1

Expert Comment

by:Munti
ID: 13402865
The above code should work fine for that then.
0
 
LVL 9

Accepted Solution

by:
sun4sunday earned 375 total points
ID: 13417650

The exception that is thrown by a strongly-typed DataSet when the user accesses DBNull value.

ie.  IF the dataset  returning the DBnull value this exception will throw.

http://www.dotnet247.com/247reference/a.aspx?u=http://www.kbalertz.com/Feedback_318039.aspx

plz give more details...

sun4sunday
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question