Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2008-10-03
3
Medium Priority
?
2,348 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 2000 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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month12 days, 19 hours left to enroll

971 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