Solved

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

Posted on 2008-10-03
3
2,323 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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

735 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