EntLib2 Data Access Block question

Topics: Data Access Application Block
Feb 1, 2007 at 10:42 PM
I wonder if someone could comment? I have a simple form. It includes a Grid, three buttons and a binding source. When the user clicks a button, the system updates the grid with a specific dataset. This works OK in the prototype and I've included the code for one of the button click events.

My question is two-fold. Does the Ent. Lib. work with typed-datasets? If not, is there a better way to reference the tables in a dataset than using dataSet.Tables0.ToString()? This question also extends to columns in a DataRow, etc. Am I missing something? The use of these indexed values seems inherently error prone.

Thanks in advance.

        private void TagRouteButton_Click(object sender, EventArgs e)
            //create a reference to the database
            Database db = DatabaseFactory.CreateDatabase("SQL Dev Instance");
            //populate the dataset
            DataSet digitalEnumDataSet = db.ExecuteDataSet(CommandType.Text, "SELECT * FROM UNF.UF_TAG_ROUTING");
            //bind the dataset to the navgrid binding source
            this.navGridBindingSource.DataSource = digitalEnumDataSet;
            *this.navGridBindingSource.DataMember = digitalEnumDataSet.Tables[0].ToString();*
            this.navGrid.DataSource = this.navGridBindingSource;
        private void ClearGrid()
            this.navGrid.DataSource = null;
            this.navGridBindingSource.DataSource = null;
            this.navGridBindingSource.DataMember = null;
Feb 2, 2007 at 2:26 AM
The DAAB does work with typed datasets. Here is an example I just cooked up:

Typed DataSets and Data Access Application Block ( DAAB )

You could just set the DataSource above directly to the table and skip the DataMember piece:

this.navGridBindingSource.DataSource = digitalEnumDataSet.Tables[0];

Of course, if you do decide to use typed datasets you can just set it to the name of the table ( using Customers as an example ):

this.navGridBindingSource.DataSource = digitalEnumDataSet.Customers;




David Hayden
Microsoft MVP C#