Click here to Skip to main content
15,886,199 members
Articles / Programming Languages / C#

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

Rate me:
Please Sign up or sign in to vote.
1.00/5 (1 vote)
22 Nov 2006CPOL2 min read 32.6K   462   15  
DatasetAdaptor encapsulates a dataset and permits automating the work between the database and the dataset.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DataDigest.Datas.Helper;

namespace DatasetAdaptorSample
{
    /// <summary>
    /// 
    /// </summary>
    /// <remarks>
    /// - think about incrementseed set to 1 in datatables when you work with datasets on datagridview...
    /// - when using an attached mdb, specify in its "Copy to Output Directory" property to "copy if newer"
    ///   in order to keep the last version of the db (mainly when debugging)
    /// </remarks>
    public partial class SampleDataSetAdaptor : Form
    {
        DataSetAdaptor<sampleDBDataSet> dtsAdaptor = null;
        public SampleDataSetAdaptor()
        {
            InitializeComponent();
            // initialize the adaptor
            dtsAdaptor = new DataSetAdaptor<sampleDBDataSet>(dataSet);
        }

        private void SampleDataSetAdaptor_Load(object sender, EventArgs e)
        {
            // download datas from db
            dtsAdaptor.Fill();
        }

        private void buttonUndo_Click(object sender, EventArgs e)
        {
            // reload datas from db
            dtsAdaptor.Fill();
        }

        private void buttonSave_Click(object sender, EventArgs e)
        {
            // update db with updates made on the dataset
            // warning, it doesn't update the content dataset with modification done in db...
            dtsAdaptor.SaveChanges();
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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


Written By
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.

Comments and Discussions