IDbDataAdapter Interface

  • Thread starter Thread starter =?iso-8859-1?Q?J=F6rgen_Bj=F6rkman?=
  • Start date Start date
?

=?iso-8859-1?Q?J=F6rgen_Bj=F6rkman?=

I declared a variable as IDbDataAdapter and instanciated
it via the Activator (Activator.CreateInstance, where the
string value was read from an ini-file). The Problem is
that the variable only accepts DataSets for Fill and
Update, I would like to pass DataTables (and DataRows)
like when the variable is declared as SqlDataAdapter or
OracleDataAdapter. Does anyone have a workaround for this?

Does anyone know if Microsoft will extend the
IDbDataAdapter interface in future releases of the .NET
Framework?
 
In general, the IDb interfaces contain a minimum set of methods/properties
that providers have to implement to support data access to thier specific
data sources. For some reason, it was decided that the Fill and other
DataAdapter methods would be working on top most data entity: the
DataSet.The doc for IdbDataAdapter also says that it is left to the provider
to implement overloads on the same.
Anyways, you can always cast the object to right type (if type is not known,
you can do a GetType) and then use the required overload. In a way, this is
not good cos the problem with this approach is that maintaining code becomes
difficult if your data access layer is supporting many providers for your
biz layer (like ODBC, Oledb, SQLClient,ODP etc)
 
What you can also do is not cast to the actual type but to the DbDataAdapter
so (IDbDataAdapterInstance as DbDataAdapter).Fill(DataTable) this will work
for the Sql, OleDb, Oracle and OleDb classes that come with .Net

Manoj G said:
.... stuff deleted
Anyways, you can always cast the object to right type (if type is not known,
you can do a GetType) and then use the required overload. In a way, this is
not good cos the problem with this approach is that maintaining code becomes
difficult if your data access layer is supporting many providers for your
biz layer (like ODBC, Oledb, SQLClient,ODP etc)
--
HTH,
Manoj G [.NET MVP]
http://www15.brinkster.com/manoj4dotnet


Jörgen Björkman said:
I declared a variable as IDbDataAdapter and instanciated
it via the Activator (Activator.CreateInstance, where the
string value was read from an ini-file). The Problem is
that the variable only accepts DataSets for Fill and
Update, I would like to pass DataTables (and DataRows)
like when the variable is declared as SqlDataAdapter or
OracleDataAdapter. Does anyone have a workaround for this?

Does anyone know if Microsoft will extend the
IDbDataAdapter interface in future releases of the .NET
Framework?
 
Back
Top