Solved

Exception:  [System.Data.OracleClient.OracleException] = {"ORA-01036: illegal variable name/number\n"}

Posted on 2008-10-03
3
2,332 Views
Last Modified: 2013-12-17
When I run this piece of code, I am getting an exception,
Exception:  [System.Data.OracleClient.OracleException] = {"ORA-01036: illegal variable name/number\n"}

Can some one please tell me why I am gettig is error

tables = Session["tables1"].ToString();
string source = (string)Session["source"];
conn = new OracleConnection(source);
string schemaOwner = ConfigurationManager.AppSettings["SchemaOwner"].ToString();
oraclecommand = new OracleCommand("select column_name,data_length,data_type from all_tab_columns where table_name = @TableName and owner = @SchemaOwner order by column_name",conn);
conn.Open();
oraclecommand.Parameters.AddWithValue("@TableName", tables.ToString());
oraclecommand.Parameters.AddWithValue("@SchemaOwner", schemaOwner);
OracleDataAdapter da = new OracleDataAdapter(oraclecommand);
DataSet ds = new DataSet();
da.Fill(ds);

Open in new window

0
Comment
Question by:sydneyram
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 22

Accepted Solution

by:
JimBrandley earned 500 total points
ID: 22635586
sydneyram
The problem is that your parameter names and placeholders are vaild for SQL Server, but not for Oracle. Oracle looks for a leading colon rather than an ampersand. Change your code to this, and it should fix this error.

Jim

tables = Session["tables1"].ToString();
string source = (string)Session["source"];
conn = new OracleConnection(source);
string schemaOwner = ConfigurationManager.AppSettings["SchemaOwner"].ToString();
oraclecommand = new OracleCommand("select column_name,data_length,data_type from all_tab_columns where table_name = :TableName and owner = :SchemaOwner order by column_name",conn);
conn.Open();
oraclecommand.Parameters.AddWithValue(":TableName", tables.ToString());
oraclecommand.Parameters.AddWithValue(":SchemaOwner", schemaOwner);
OracleDataAdapter da = new OracleDataAdapter(oraclecommand);
DataSet ds = new DataSet();
da.Fill(ds);
0
 

Author Closing Comment

by:sydneyram
ID: 31502797
Thank you so much. It solved my problem
0
 
LVL 22

Expert Comment

by:JimBrandley
ID: 22636267
Glad that worked. Good luck.

Jim
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question