PC Review


Reply
Thread Tools Rate Thread

Alternative for DeriveParameters? (ADO.NET 2.0)

 
 
James Tharpe
Guest
Posts: n/a
 
      7th Nov 2005
Hello,

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


 
Reply With Quote
 
 
 
 
Kevin Yu [MSFT]
Guest
Posts: n/a
 
      8th Nov 2005
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."

 
Reply With Quote
 
James Tharpe
Guest
Posts: n/a
 
      11th Nov 2005
> 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.


I can't cast it if I don't know what it is. I did find a workaround though,
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


 
Reply With Quote
 
Kevin Yu [MSFT]
Guest
Posts: n/a
 
      12th Nov 2005
Hi James,

Yes, we can call it through reflection, but the DeriveParameter method is
provider specific. Some other providers might not support that.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Google Adsense Alternative - Commission Junction Alternative -ClickBank Alternative William9999 Windows XP Performance 0 2nd Nov 2010 09:02 AM
Google Adsense Alternative - Commission Junction Alternative -ClickBank Alternative William9999 Windows XP Performance 0 2nd Nov 2010 09:01 AM
DbCommandBuilder.DeriveParameters Ale Microsoft ADO .NET 1 6th Jul 2009 10:21 AM
DeriveParameters =?Utf-8?B?Q2h1Y2sgUA==?= Microsoft ADO .NET 9 21st Nov 2006 05:09 AM
Re: OracleCommandBuilder: DeriveParameters David Browne Microsoft ADO .NET 0 14th Jul 2003 05:34 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:11 AM.