Trouble retrieving data from a dataset to a datarow.

  • Thread starter Thread starter Dirk Vervecken
  • Start date Start date
D

Dirk Vervecken

Hi,

I'm trying to fill a dataRow from a dataset. But now i'm wondering,
what do i do if the Dataset does not contain the requested
information?

For Example :
c_CompGroupRij = c_dsCompGroup.tComponentGroup.FindByCompgroupId(cGroupId);

I try to find a row in the Dataset (c_dsCompGroup) that has cGroupId
as an ID, in order to display this row on screen.
But if It does not contain that ID, how do I check this before I do
this:
this.cGroupName = c_CompGroupRij.Cgroupname;
this.IsActive = c_CompGroupRij.IsActive;

Thanks
Dirk Vervecken
 
Dirk,

I would think that your FindByCompgroupId method would return null, or
an array with zero elements in it. You should check for either or both of
these cases.

Also, you can look in the code for this class (the strongly typed
datasets are just pieces of code inserted into your project) to see what the
return result is. However, I believe that these functions are based on the
Select method on the DataTable class, which should return an array with zero
elements. However, it never hurts to check against null.

Hope this helps.
 
Back
Top