473,320 Members | 2,048 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,320 software developers and data experts.

ODP.NET OracleCommand.CommandText conversion error

I am running the following lines...

Expand|Select|Wrap|Line Numbers
  1.             OracleConnection connection=new OracleConnection("myConnectionStringIsHere");
  2.             connection.Open();
  3.             var startValueParameter=new OracleParameter {ParameterName="@START_VALUE", Value=0};
  4.             var chunkSizeParameter=new OracleParameter {ParameterName="@CHUNK_SIZE", Value=10};
  5.             var command=new OracleCommand
  6.                             {
  7.                                 Connection=connection,
  8.                                 CommandType=CommandType.Text
  9.                             };
  10.                 command.CommandText = "select EmployeeID, test_id from ExampleTable where (test_id > :START_VALUE) AND (rownum <= :CHUNK_SIZE)";

The error I get is on the very last line where I try to set command.CommandText.

System.InvalidCastException: Unable to cast object of type 'System.String' to type 'Oracle.DataAccess.Client.OracleConnection'

This is very strange, as it suddenly started happening out of the blue. Any suggestions? Thanks.
Sep 21 '09 #1
7 6950
Plater
7,872 Expert 4TB
Is the colorization of the text abnormal in your visual studio? If one of those quotes is not closed, it could be trying to interpret a whole section of your code as a connection string.

Is this not c#? Because "var" isn't a normal object type in C#. Are you getting mixed up with javascript?
Sep 21 '09 #2
'var' is new to C# 3.0
http://msdn.microsoft.com/en-us/library/bb383973.aspx

Also, it is not including anything abnormal in the connectionstring or the commandtext. All quotes are accounted for.
Sep 21 '09 #3
Plater
7,872 Expert 4TB
@pieps86
I thought of that after I had posted.
Hmm and you have debug stepped through to make sure nothing is mangling your objects?
Sep 22 '09 #4
Nope, nothing is getting skewed anywhere along the way. I even compared this code with older versions in Team Explorer to see if I could find anything that had been changed recently that would cause this error. Also, the problem only seems to be when I debug the project from within Visual Studio. I can put the DLL with this code in an engine and it runs fine.
Sep 22 '09 #5
ssnaik84
149 100+
"var" is introduced for LINQ and you can use it in case of lazy binding; where you dont know the data type at compile time.
if you will use it, application will run.. but you cant debug...
Sep 22 '09 #6
I don't know about that. I am, in fact, debugging to get this error. Using the 'var' keyword is not the issue. I can explicitly declare all types and still get the same result. Nonetheless, using 'var' does not prevent debugging. I'm in VS2008, btw.
Sep 23 '09 #7
Plater
7,872 Expert 4TB
So the error ONLY comes up in debugging, and not in a regular release?
That is very strange. Only thing I can think of is if you are pulling and values from the Properties section, they will be different between regular and debug runs.
Sep 23 '09 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

30
by: Tim Johansson | last post by:
I'm new to C++, and tried to start making a script that will shuffle an array. Can someone please tell me what's wrong? #include <iostream.h> #include <string.h> int main () {...
1
by: Michael.EJ.Reynolds | last post by:
I'm having a ton of trouble with a dataset. It builds at design time, but fails at runtime, saying: --------------------------- Processing Errors --------------------------- An error has...
7
by: Michael Lehn | last post by:
Hi, I have a question regarding the conversion of objects. When is the conversion done by the constructor and when by the operator. My feeling tells me that the constructor is preferred. But...
11
by: Steve Gough | last post by:
Could anyone please help me to understand what is happening here? The commented line produces an error, which is what I expected given that there is no conversion defined from type double to type...
3
by: Richard Lewis Haggard | last post by:
While looking at information on OracleCommand class, I was surprised to see the Microsoft documentation saying "Note: This namespace, class, or member is supported only in version 1.1 of the .NET...
3
by: fazulu deen | last post by:
Hi all, For the following code : file_ptr = fopen("pass_fail.txt", "a"); // error line 393 fdisplay(file_ptr, "Test Passed"); fclose(file_ptr);
0
by: =?Utf-8?B?Sm9uIEphY29icw==?= | last post by:
When I update a small table, no problem. When I Update a single field on a single row in a large table, OracleCommand.ExecuteNonQuery hangs and never comes back. Note, the where clause specifies a...
6
by: Rahul | last post by:
Hi Everyone, I have the following code, class B; class A { public : operator B();
1
by: gecko | last post by:
Hi, Regarding : OracleCommand.ExecuteNonQuery() Lets say I want to delete a record from a table and this deletion triggers other deletions from other tables. So, does the number of rows...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.