I can't get this to work either...
I started building a generic update routine from a DataRow. You pass in a row and it auto-gens a command that runs the update or insert. Except for the Parameter issue it's all generic. I don't think this can be done, at least I couldn't figure it out.
I moved that method into my data access layer now and from there I can call CreateParameter which returns me an IDbDataParameter from the current provider. It works but is not how I wanted to do this <g>...
That seems like a real missing feature since all providers can in fact retrun a parmaeters through their Add methods. But it's a different collection for each and those collections do not inherit from IDataParameterCollection. It's a design flaw that breaks the whole 'Interface' based access mechanism.
I remember running into this before in my business objects - whenever I need a parm object I coudlnt' get it. at least now I got smart and added CreateParameter() to the data layer and that at least will help make the business layer generic.
+++ Rick ---
>Hey Rick,
>
>That is a tricky one ... it looks to me like it's blowing up on the
>
>int index = Command.Parameters.Add("@PkField");
>
>statement. I tried changing it to:
>
>int index = Command.Parameters.Add(Row[PkField]);
>
>and it still didn't like it. From the error message, it looks like it's expecting to be adding an already defined Parameter and I can't figure out how to create that Parameter object using only IDbDataParameter. The error says:
>
>The SqlParameterCollection only accepts non-null SqlParameter type objects, not Int32 objects.
>
>Have you figured it out yet?
>
>~~Bonnie