Jarod - the FillDataSet was the method I was speaking of. In practice, I
actually augmented it to have a FillTypedDataSet method and the only
difference is essentially that I have another parameter for the
tablemappings/columnmappings.
Also, although this isn't exactly what you asked origianlly, just as an FYI,
you can use a TypedDataset in the place of where you're expecting an
Untyped one - just not the other way around:
private void button1_Click(object sender, System.EventArgs e) {
DataSet dss = FillDataSet();
MessageBox.Show(dss.Tables.Count.ToString());
}
private Dataset1 FillDataSet(){
Dataset1 ds = new Dataset1();
DataTable dt = new DataTable();
DataColumn dc = new DataColumn("TestColumn", typeof(System.String));
dt.Columns.Add(dc);
ds.Tables.Add(dt);
DataRow dro = dt.NewRow();
dro[0] = "Bill Ryan";
dt.Rows.Add(dro);
return ds;
}
But ultimatey my point is that in this instance, you can easily add an
augmented method to your SqlHelper class as we did, FillTypedDataSet and
since it's a reference type, when you pass it in, any changes made to it
will be made to the origianl (I know, many purists say that you should use
return values instead but I honestly don't see anything wrong with this
approach).
On a scale of 1-10, it's about a 3 to add this in, and you can reuse it
everywhere (Typed Dataset have many many things to like about them, and not
having to worry about getting the colum names right is one of the bigger
ones) so it's a great component to build that you can use all over the
place. I'll be glad to walk you through it.
Cheers,
Bill
--
W.G. Ryan, MVP
www.tibasolutions.com |
www.devbuzz.com |
www.knowdotnet.com
"Jarod" <(E-Mail Removed)> wrote in message
news:FEE4EDEF-C1B7-4F2B-84B4-(E-Mail Removed)...
>> Jarod - why not just fill the Typed DataSet in the first place. There's
>> not
>> a direct convert function and I'm pretty sure you'd have to write your
>> own
>> dataset to accomplish this implementing IConvertible for instance. I've
>> seen a lot of people do stuff like pass in a regular dataset to
>> SqlHelper,
>> then loop through it copying the rows and then putting them in the typed
>> dataset (there's so much wrong with approaches like this it's hard to
>> know
>> where to begin). It's a LOT easier to just fill the typed dataset from
>> the
>> get go. DataSets are often pretty big too and consume a good bit of
>> memory,
>> so creating one, just so you can convert it to another type and then
>> destroy
>> it is definitely not an approach that will scale well,
>>
>> As an aside, check this out:
>>
>> private void button1_Click(object sender, System.EventArgs e) {
>>
>> Dataset1 dss = new Dataset1();
>>
>> FillDataSet(dss);
>>
>> }
>>
>> private void FillDataSet(DataSet ds){
>>
>> MessageBox.Show(ds.Tables.Count.ToString());
>>
>> }
>
>
> SqlHelper.ExecuteDataSer(...) it returns DataSet ( untyped
so I need to
> find a way for it to convert. My datasets will be really small only a few
> rows. So the scalability don't matters. Maybe you can show me how to
> invoke
> stored procedure by using sqlhelper and then use typed dataset.
> Jarod