I'm trying to figure out how to generically create SQL statements in my bus object without having to specify a backend specific SqlCommand object.
I have a reference to an IDbCommand object, but I can't figure out how to get a generic Parameter created for me unless I use a specific instance instead of the Interface reference.
I can do:
SqlCommand Command = SomeCommandThatExists;
SqlParameter Parm = Command.Parameters.Add(...);
Unfortunately that doesn't work with IDbCommand as the collection is just a generic list interface, that doesn't a specific implementation...
IDbCommand Command = (IDbCommand) SomeSqlCommandThatExists;
int index = Command.Parameters.Add("@PkField");
IDbParameter Parm = Command.Parameters[index]; // nope
Parm.Value = Row[PkField];
This doesn't work (along with a few other approaches I've tried). The error I get is that only Sql type values are allowed... What is supposed to be passed there, the value???
The docs are wrong on this one or describe something different.
So... how do I do this generically without hardcoding the implementation with a switch() to the particular data backend used?
+++ Rick ---