Solved

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

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

758 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now