Click here to Skip to main content
13,355,726 members (60,770 online)
Click here to Skip to main content
Add your own
alternative version


15 bookmarked
Posted 6 Nov 2006

How to automate work when working with a Typed Dataset against a database (CSC)

, 22 Nov 2006
Rate this:
Please Sign up or sign in to vote.
DatasetAdaptor encapsulates a dataset and permits automating the work between the database and the dataset.

Sample Image - DatasetAdaptor.jpg


Have you always wanted to be able to update a dataset in a batch, or fill its contents from a database with just one command? I have... in a project 10 months ago, I thought about it, but I had then never heard about Reflection.

After reading, profiling, factoring and refactoring.. reading again... I'm beginning to understand that Reflection allow us to do every thing...

With this tool, you will be able to fill or update a whole dataset with two lines of code...

I decided to write this when making searching for a tool which could enable something like this... I discovered the mocosh tool which seemed really useful. I didn't test it, but I understood from the screenshot that generated classes should be quite easy to combine...


This tool is a tracking tool for ASP.NET. I wanted to do batch updates every hour on the database to minimize calls to it. It doesn't assume any transactions (currently).

Also, as I wrote this for my project, I made every test specifically for my database schema.


  1. DataSetAdaptor
  2. Encapsulates a dataset and permits automating the work between the database and the dataset.

  3. HlpReflexion
  4. Contains some useful methods to work with Reflection.</li />

How to use it

  1. Create your database.
  2. Create your DataSet in Design mode by drag & dropping a table on this to ensure the creation of table adaptors. In fact, you have to do this to ensure the naming conventions of TableAdapters generated by CSC are followed. If you want to work in a different way... I propose extending DataSetValidator and overriding the GetAdapter method (see the remarks in the class).
  3. Declare your DataSet in your application as usual.
  4. Add a reference of DataDigest.Datas.Helper in your project, or copy the classes in it.
  5. Instantiate the DataSetAdapter for your DataSet as you would with a TableAdapter for a DataTable.
  6. DataSetAdaptor<typedDataSet><SAMPLEDBDATASET> dtsAdaptor 
        = new DataSetAdaptor<typedDataSet>(dataSet);
  7. After this is done, you'll want to download data from the database and fill in the dataset:
  8. dtsAdaptor.Fill();
  9. Later, when you want to update the database....
  10. dtsAdaptor.Update();


I know that using generics in this case is not useful, but I think this tool has a future. It may be useful to recover the typed encapsulated dataset without casting.


Use this for non-critical applications. Datasets are only useful for these kinds of application in my opinion. For good maintenance, I have only one word... NHibernate.


Sorry about my poor English.


  • 06-11-22: Handles exceptions at filling and saving time. Warning: there is no transactions support.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Other UMH
Belgium Belgium
* Bachelor of Information Management at ISAT Charleroi in Belgium.
* Master II of Information science at UMH Mons.

I spend my time in small projects which can help me or small enterprises and
I am very interested in designing projects
with specifications of UML or in applying usual design patterns.

You may also be interested in...


Comments and Discussions

GeneralContinued in an other article Pin
BlaiseBraye29-Nov-06 5:03
memberBlaiseBraye29-Nov-06 5:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.180111.1 | Last Updated 22 Nov 2006
Article Copyright 2006 by BlaiseBraye
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid