How to move datasets around

  • Thread starter Thread starter grs
  • Start date Start date
G

grs

What is the recommended method of moving datsets around in code.
Do you use 1 or 2 below or does it make a difference.

1. public void CreateDataSet(DataSet aDataset)
or
2. public DataSet CreateDataSet()
return dataset

thanks
 
grs,

Why not do both and let the caller decide? This way, you can have a
dataset that is populated correctly, or you can just create a new one and
return that. As a matter of fact, your code will just look like this:

public DataSet CreateDataSet()
{
// Create the return value.
DataSet ds = new DataSet();

// Populate.
CreateDataSet(ds);

// Return.
return ds;
}

public void CreateDataSet(DataSet dataSet)
{
// Initialize here.
}

The only thing I would do is change the overload of CreateDataSet that
takes the data set parameter so that the name is InitializeDataSet, since
you arent really creating one.

Hope this helps.
 
Back
Top