HighTechTalks DotNet Forums  

Remove row with null value from DataSet??

ASP.net Web Services microsoft.public.dotnet.framework.aspnet.webservices


Discuss Remove row with null value from DataSet?? in the ASP.net Web Services forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
LunchBox
 
Posts: n/a

Default Remove row with null value from DataSet?? - 12-04-2003 , 11:27 AM






I'm getting null values in a DataSet which is pulling its data from a web
service. The nulls are creating 'System.Data.ConstraintException' in the
fields that do not allow columns. I've tried finding the reason for the
nulls, but I'm out of time. I need to erase the rows with nulls from the
dataset. Here is what I have so far, and although it throws an Invalid
Operation exception, it does delete the row with the null. But obviously I
don't want to just leave it throwing exceptions. Is there a better way to
do this?

Here's my code:

try
{
DataTable dt = Dataset1.Data;
if(Dataset1.Data.HasErrors)
{
foreach(DataRow dr in dt.Rows)
{
if(dr.IsNull("ID"))
dr.Delete();
}
Dataset1.Clear();
Dataset1.Merge(dt);
}
}
catch(Exception e){MessageBox.Show(e.GetBaseException().ToString() );}

Thanks.




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.