DbDataAdapter and RowUpdated event

  • Thread starter Thread starter Michael Russell
  • Start date Start date
M

Michael Russell

I'm working on a small app that will talk to different databases, and so
far it's been working great using a generic database factory model.
However, I've run into a situation where I need to be catching some
DataAdapter events, and found that I can't.

So I'm asking, is there an easy way to do this other than subclassing my
class to handle SqlDataAdapter, ODBCDataAdapter, and whatever else I may
run into in the future?

Thanks,
Michael
 
Michael said:
I'm working on a small app that will talk to different databases, and so
far it's been working great using a generic database factory model.
However, I've run into a situation where I need to be catching some
DataAdapter events, and found that I can't.

So I'm asking, is there an easy way to do this other than subclassing my
class to handle SqlDataAdapter, ODBCDataAdapter, and whatever else I may
run into in the future?

Thinking about this a little more, do I run the risk of problems if I do
something like this?:

if ( GenericDbFactoryHelper.CurrentFactory == "SqlClientFactory" ) {
((SqlDataAdapter)daFarm).RowUpdated += new
SqlRowUpdatedEventHandler( daFarm_OnRowUpdate );
} else {
throw new Exception( "Db Factory not supported: " +
GenericDbFactoryHelper.CurrentFactory );
}

Then have an event handler method for each type of database? Obviously,
I'd use a switch rather than if...then... else, this is just to demo the
idea.

Michael
 
Back
Top