Fog Creek Software
Discussion Board

Welcome! and rules

Joel on Software

update through datagrid

What is the best way to update data from the windows datagrid control? we really don't want to use the command builder. We would like to use the stored procedure in this case. If we use the stored procedure in the updatecommand of the dataadapter and change 5 rows in the datagrid, will it cause 5 trips to db?

We are using Oracle as our datasource and using 1.1 framework.

Saturday, December 6, 2003

"will it cause 5 trips to db" -- yes. Unless your database is on the end of a 28.8K modem from the client, I doubt if this will really be that much of an issue.

Duncan Smart
Monday, December 8, 2003

Yes it is not a big issue when we are talking about 5 records but it could be a design concern when more records are edited through the datagrid.

What do you think is the right approach? even if we use stored procedure, how do we take care of "optimistic concurrency" issue? Is there any code example?

Monday, December 8, 2003

Check the MSDN for DBConcurrencyException class.

.NET Developer
Monday, December 8, 2003

"...could be a design concern when more records are edited through the datagrid"

What's the alternative? A cursor? Cursors don't scale all that well and, as such, have fallen out of favour. Disconnected mode (using DataSets) is the key way to do it in .NET currently. You could code into your app (by hooking events in the DataSetr/DataTable) an automatic DataAdapter Update once a certain "dirty row" limit is met, or a timeout.

By default, concurrency is taken care of by the DataSet storing the "before" and "after" and the DataAdapter comparing your "before" with the database's current data immediately prior to doing the update -- if someone's changed it you get the exception mentioned by the above poster.

If you can change the schema of the db consider using timestamps on records, which would make such concurrency checking more straightforward.

Duncan Smart
Tuesday, December 9, 2003

*  Recent Topics

*  Fog Creek Home