473,394 Members | 1,714 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Converting IDataParameter to IDbDataParameter

Hi,

I am using some code that was written for common use within my company
that has a Parameter object that inherits from IDataParameter.
However, a whole other piece of code that we use for querying the
database has methods in it that need to take in a variable of type
IDbDataParameter (yes, I know, communication was not evident here!).

Anyways, is there anyway to convert an IDataParameter value to an
IDbDataParameter one without writing a ton of code? I tried a simple
cast and it failed.

May 17 '06 #1
3 7261
And what's the error did u get? Could you demonstrate your code

"Doug" wrote:
Hi,

I am using some code that was written for common use within my company
that has a Parameter object that inherits from IDataParameter.
However, a whole other piece of code that we use for querying the
database has methods in it that need to take in a variable of type
IDbDataParameter (yes, I know, communication was not evident here!).

Anyways, is there anyway to convert an IDataParameter value to an
IDbDataParameter one without writing a ton of code? I tried a simple
cast and it failed.


--
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche

May 17 '06 #2
Hi,

Why using a IDbDataParameter ? IIRC this is especific to VB.net

You can convert an IDbDataParameter to IDataParameter , the opposite don't
think that is possible, you would have to manually create it :(
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Doug" <dn******@dtgnet.com> wrote in message
news:11**********************@38g2000cwa.googlegro ups.com...
Hi,

I am using some code that was written for common use within my company
that has a Parameter object that inherits from IDataParameter.
However, a whole other piece of code that we use for querying the
database has methods in it that need to take in a variable of type
IDbDataParameter (yes, I know, communication was not evident here!).

Anyways, is there anyway to convert an IDataParameter value to an
IDbDataParameter one without writing a ton of code? I tried a simple
cast and it failed.

May 17 '06 #3
Sure:

IDataParameter[] parameters = new IDataParameter[1];
parameters[0] = new Parameter("@PRGRM_ENTR_ID", DbType.Int32,
programId);
return (IDbDataParameter[])parameters;

The "new Parameter" line is referring to our common component that has
a Parameter class that inherits from IDataParameter. However I need an
IDbDataParameter to use in a method a few lines later (for querying)
and so am trying to cast it as you can see.

I get a "Specfied Cast Not Valid" error when I try to do what I'm doing
above.

May 17 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: mustafa | last post by:
Dear sir , I have built my application in visual basic 6.0 and crystal Report8.5 , Now i migrated my application to VB.net using the upgrade wizard.My visual basic form is upgraded to vb.net...
29
by: Armand Karlsen | last post by:
I have a website ( http://www.zen62775.zen.co.uk ) that I made HTML 4.01 Transitional and CSS compliant, and I'm thinking of converting it into XHTML to learn a little about it. Which XHTML variant...
8
by: prabha | last post by:
Hello Everybody, I have to conert the word doc to multiple html files,according to the templates in the word doc. I had converted the word to xml.Also through Exsl ,had finished the multiple...
5
by: Robert | last post by:
I have a series of web applications (configured as separate applications) on a server. There is a main application at the root and then several virtual directories that are independant...
3
by: Mary | last post by:
Hi, Does anyone know of any software out there that would convert an application written in VBScript to either VB.NET or C#/C++ quite quickly for me, or will I have to re-write the application...
7
by: Tor Aadnevik | last post by:
Hi, I have a problem converting values from Single to double. eg. When the Single value 12.19 is converted to double, the result is 12.1899995803833. Anyone know how to avoid this? Regards...
2
by: shenanwei | last post by:
DB2 V8.2 on AIX, type II index is created. I see this from deadlock event monitor. 5) Deadlocked Connection ... Participant no.: 2 Lock wait start time: 09/18/2006 23:04:09.911774 .........
2
by: Fred Chateau | last post by:
Could someone please tell me how to create an array using the IDbDataParameter? -- Regards, Fred Chateau fchateauAtComcastDotNet
0
by: Ryan Liu | last post by:
Why IDataParameterCollection.Item return an object, not a IDataParameter? Like DbParameterCollection .GetParameter() -DbParameter Thanks! Ryan
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.