Link to home
Start Free TrialLog in
Avatar of TYB
TYB

asked on

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

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.
Avatar of Munti
Munti

what is the exception?
Avatar of TYB

ASKER

An unhandled exception of type 'System.Data.StrongTypingException
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...";
}
}
Avatar of TYB

ASKER

The web service return the dataset as return value.

MyWebservice myService = new MyWebservice();

DataSet dSet = new DataSet();

dSet = myWebService().GetAll();
The above code should work fine for that then.
ASKER CERTIFIED SOLUTION
Avatar of sun4sunday
sun4sunday
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial