Add custom methods to Strong DataSet

S

Steve Amey

Hi all

I have created a strong DataSet using Visual Studio. I have been in to the
DataSet's vb file to have a look at the code and see if I can add things to
it. What I'm after is to create a new method on every DataTable in the
DataSet, this method will be called SelectToTable, as I have the need to
select rows in a current table into another table, and the Select method
only returns an array of data rows. However, any changes that I make are
overwritten the next time I edit and save the DataSet in the designer. Is
there a way to add custom functionality to the DataTables and not have them
overwritten the next time I change something in the designer?

Kind regards,
Steve
 
S

stand__sure

in a separate file, inherit from the class and extend it -- this will give
you the functionality without having the tool overwrite your source
 
S

Steve Amey

Hiya

Thanks for the suggestion. I now have a Class that inherits the DataSet, but
how do I get the methods on the DataTable objects themselves? Sorry if it's
easy, I haven't done stuff like this before. Currently I have the
SelectToTable method on the DataSet, so it can be called like this:

Dim oDataSet As New MyDataSet
oDataSet.SelectToTable(filterExpression)

Whereas I would like the following:

Dim oDataSet As New MyDataSet
oDataSet.MyTable.SelectToTable(filterExpression)

So the function would return a table of the same type, just with records
that match the filterExpression. I know I could pass through a table or
table name to the DataSet method, but I would prefer it if possible on each
of the DataTables in the DataSet.

Thanks for your continued help!

Steve.
 
D

David

Hi all

I have created a strong DataSet using Visual Studio. I have been in to the
DataSet's vb file to have a look at the code and see if I can add things to
it. What I'm after is to create a new method on every DataTable in the
DataSet, this method will be called SelectToTable, as I have the need to
select rows in a current table into another table, and the Select method
only returns an array of data rows. However, any changes that I make are
overwritten the next time I edit and save the DataSet in the designer. Is
there a way to add custom functionality to the DataTables and not have them
overwritten the next time I change something in the designer?

No, there's not. The built-in strongly-typed dataset doesn't provide
the functionality to make this design reasonable, although it would be a
very useful way to do things. it's simple enough to inherit from the
dataset, but as you've found, much more difficult to create a usable
subclass of DataTables or typed rows or such.

There's a bunch of alternatives to the standard DataSet out there that
can do this kind of thing. AGDataSetGenerator is one of the more
popular addins that do this (google for it).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top