Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
IDbCommand IDbDataParameter logistics
Message
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Titre:
IDbCommand IDbDataParameter logistics
Divers
Thread ID:
00863398
Message ID:
00863398
Vues:
88
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 ---
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform