|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Alternative for DeriveParameters? (ADO.NET 2.0)My application *only* uses the base-classes (e.g. DbCommand, DbParameter) for data access and uses DbProviderFactories/DbProviderFactory to create the concrete classes. That said, I need the functionality of the DeriveParameters static method that is part of the various xxxCommandBuilder classes. So my question is: if I don't know which client is being used, how can I call DeriveParameters? Is there a non-static equivalent (I couldn't find one)? Or, is there a way to do this using reflection? An example would be great, and all help is appreciated. Thanks! -- -James Blog: http://blogs.remobjects.com/blogs/jimmy/ Furl: http://www.furl.net/members/jimmytharpe Hi Jame,
The DeriveParameters method is specify for providers. If you don't know the provider, it's hard to call DeriveParameters method. You can try to cast the object into desired type and then call DeriveParameter method. There is no elegant way in this case, AFAIK. Kevin Yu ======= "This posting is provided "AS IS" with no warranties, and confers no rights." > The DeriveParameters method is specify for providers. If you don't know I can't cast it if I don't know what it is. I did find a workaround though, > the > provider, it's hard to call DeriveParameters method. You can try to cast > the object into desired type and then call DeriveParameter method. There > is > no elegant way in this case, AFAIK. using reflection: DbCommand command = DbFactory.CreateCommand(); // [Snip] code to and assign values to command Type commandBuilderType = DbFactory.CreateCommandBuilder().GetType(); MethodInfo deriveParametersMethodInfo = commandBuilderType.GetMethod("DeriveParameters"); if(deriveParametersMethodInfo != null){ object[] deriveParametersMethodArgs = { command }; deriveParametersMethodInfo.Invoke(null, deriveParametersMethodArgs); } -- -James Blog: http://blogs.remobjects.com/blogs/jimmy/ Furl: http://www.furl.net/members/jimmytharpe |
|||||||||||||||||||||||