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.
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.
what is the exception?
ASKER
An unhandled exception of type 'System.Data.StrongTypingE xception
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"/inde x].Rows)
{
for(int i=0;i<row.items.length;i++ )
{
if(row[i].ToString() == "")
row[i] = "put your value here...";
}
}
foreach(DataRow row in ds.Tables["tablename"/inde
{
for(int i=0;i<row.items.length;i++
{
if(row[i].ToString() == "")
row[i] = "put your value here...";
}
}
ASKER
The web service return the dataset as return value.
MyWebservice myService = new MyWebservice();
DataSet dSet = new DataSet();
dSet = myWebService().GetAll();
MyWebservice myService = new MyWebservice();
DataSet dSet = new DataSet();
dSet = myWebService().GetAll();
The above code should work fine for that then.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.