SqlParameter is an implementation of an 'Adapter' pattern. This allows
things like DataAdapter and DataReader to be able to use generic methods for
using these objects without concern for which database lies underneath it.
If you have a database (that is not either SQL Server or Oracle) that you
want to access, simply creating objects that meets the same interface
(MarshalByRefObject, IDbDataParameter, IDataParameter, ICloneable) will
allow your methods to be used by the higher-level database objects.
In other words, .Net already does this for you.
What .Net doesn't do is provide you with an abstract factory. You can
easily write one that returns an object of type IDbDataParameter when you
want to create a new parameter object. Then you can use your factory to
create generic objects, and in fact, can use these objects as generic ones
(cross db) without knowing if the factory is connecting you to SQL Server
objects, Oracle objects, or another set of Adapter objects.
Please read up on the Abstract Factory pattern.
http://www.dofactory.com/Patterns/PatternAbstract.aspx
--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik
Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"SimonH" <no**@hotmail.com> wrote in message
news:93********************@news.microsoft.com...
Hi all,
I would like to make a generic set of methods that could be called
regardless of the database behind the scenes.
One of the methods I would like would take a string sql statement and an
array of DataParameter objects.
The problem i have is there doesnt seem to be a generic DataParameter
class that I can instantiate. There only seems to be specific implementations
like SQLParamater and so on.
The is an interface called IDataParameter or something to that effect, but
of course I can't instantiate an interface.
I need to be able to work with a non-specific parameter object.
Does anyone know what I could do?
Many thanks all
Kindest Regards