using RowUpdated & RowUpdating events with DbDataAdapter

Topics: Data Access Application Block
Sep 17, 2009 at 3:34 PM

Hi All,


I'm new to EntLib. I had been using the regular SQLDataAdapter all these days. Now I moved to EntLib. I used to use the RowUpdated & RowUpdating events with SQLDataAdapter. How can I use them with DbDataAdapter here.


I created an adapter saying DbDataAdapter da = new DbDataAdapter(); But I dont see the RowUpdated & RowUpdating events when I say da dot.


Can someone plz help me? this is the only one left out for me. I had a few other issues which I fixed.




Sep 18, 2009 at 7:30 AM


I think you can still use the SqlDataAdapter against the DAAB. I tried it and seems to be working fine:

            Database db = DatabaseFactory.CreateDatabase();
            DbConnection connection = db.CreateConnection();

            const string queryString = "SELECT * FROM [NewProjects]";

            // create DataAdapter
            SqlDataAdapter adapter = new SqlDataAdapter(queryString, (SqlConnection)connection);
            SqlCommandBuilder builder = new SqlCommandBuilder(adapter);
            // Create and fill DataSet (select only first 5 rows)
            DataSet dataSet = new DataSet();
            adapter.Fill(dataSet, 0, 5, "Table");

            // Modify DataSet
            DataTable table = dataSet.Tables["Table"];
            table.Rows[0][1] = "new product3";

            // add handlers
            adapter.RowUpdating += new SqlRowUpdatingEventHandler(OnRowUpdating);
            adapter.RowUpdated += new SqlRowUpdatedEventHandler(OnRowUpdated);

            // update, this operation fires two events 
            // (RowUpdating/RowUpdated) per changed row 
            adapter.Update(dataSet, "Table");
Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
Sep 18, 2009 at 12:31 PM

HI  Valiant,

Thanks for the response. Is using SQLDataAdapter the only option available here. Is there no way to get the DbDataAdapter get working here???

The reason I ask this is, If the SQLDB changes to OracleDB, then I would end up in changing the code, I was trying to avoid this. Plz let me know.




Sep 22, 2009 at 8:25 AM

Hi Bob,

I did some googling about this, i found a post stating that its a issue with the current framework. Also they give some possible workaround for the issue.

Please see these links:

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.