Solved

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

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
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 …

860 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