Click here to Skip to main content
15,894,540 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
"One or more errors occurred during processing of command.
ORA-00936: missing expression "

error name


table is test3 with one attribute name varchar2(20)

coding is
C#
public string show(string country)
{
string var;

            OleDbConnection cn = new OleDbConnection("Provider=MSDAORA.1;User ID=system;password=tiger;Data Source=XE;Persist Security Infor=False"); 
            
                       
            try
            {
                cn.Open();
                string s = "insert into test3(NAME) values(@nam)";


                OleDbCommand cmd = new OleDbCommand(s, cn);
                cmd.Parameters.AddWithValue("@nam", country);
 
                cmd.ExecuteNonQuery(); 
                var="success";
            } 
            catch (OleDbException e1) 
            { 
                Console.Write(e1.Message);
                Console.Write(e1.StackTrace);
                var = e1.Message;
            }
            cn.Close();
            return var;
}
Posted
Updated 23-Jul-13 7:49am
v3
Comments
ZurdoDev 23-Jul-13 13:11pm    
What's the value of country?
Member 8780842 23-Jul-13 13:37pm    
country is passed as parameter
ZurdoDev 23-Jul-13 13:48pm    
I know, what is the value though. The error indicates you have a syntax issue.
ZurdoDev 23-Jul-13 13:49pm    
You may need to put single quotes in your statement.

insert into test3(NAME) values('@nam')

2 issues:
1) I don't know that "@" is a valid character for identifying parameters in Oracle
2) When you add the parameter and specify the name, do not use the escape character

So more like this:
C#
string s = "insert into test3(NAME) values(:nam)";

and
C#
cmd.Parameters.AddWithValue("nam", country);
 
Share this answer
 
Comments
CHill60 23-Jul-13 14:00pm    
Sorry for the overlap on solutions - you can type faster than me :-)
I don't think that OLEDb supports named parameters in the command ... try the following instead (warning - my syntax might not be perfect)
string s = "insert into test3(NAME) values(?)";
OleDbParameter pNamVal = New OleDbParameter("@nam", OleDbType.Varchar2, 20)
 pNamVal.Value = country
 
Share this answer
 
Comments
Member 8780842 24-Jul-13 3:39am    
I tried this sir

public string show(decimal busid,decimal totalseats,string bustype,string journeydate,string arrtime,string depttime,string source,string destination,decimal ticketprice,string bpoint,string dpoint)
{
string var;

OleDbConnection cn = new OleDbConnection("Provider=MSDAORA.1;User ID=system;password=tiger;Data Source=XE;Persist Security Infor=False");


try
{
cn.Open();
string s = "Insert into busdetails(BUS_ID,TOTAL_SEATS,BUS_TYPE,JOURNEY_DATE,ARR_TIME,DEPT_TIME,SOURCE,DESTINATION,TICKET_PRICE,B_POINT,D_POINT) values(:busid,:totseats,:bustype,:jdate,:arrtime,:dtime,:source,:dest,:tickprice,:bpoint,:dpoint)";


OleDbCommand cmd = new OleDbCommand(s, cn);
//@busid,@totseats,@bustype,@jdate,@arrtime,@dtime,@source,@dest,@tickprice,@bpoint,@dpoint
cmd.Parameters.AddWithValue("busid", Convert.ToDecimal(busid));
cmd.Parameters.AddWithValue("totseats", Convert.ToDecimal(totalseats));
cmd.Parameters.AddWithValue("bustype", bustype);
cmd.Parameters.AddWithValue("jdate", journeydate);
cmd.Parameters.AddWithValue("arrtime", arrtime);
cmd.Parameters.AddWithValue("dtime", depttime);
cmd.Parameters.AddWithValue("source", source);
cmd.Parameters.AddWithValue("dest", destination);
cmd.Parameters.AddWithValue("tickprice", Convert.ToDecimal(ticketprice));
cmd.Parameters.AddWithValue("bpoint", bpoint);
cmd.Parameters.AddWithValue("dpoint", dpoint);

cmd.ExecuteNonQuery();
var="success";
}
catch (OleDbException e1)
{
Console.Write(e1.Message);
Console.Write(e1.StackTrace);
var = e1.Message;
}
cn.Close();
return var;
}
}

table format is
bus_id not null nummber(6,2)
total_seats number
bus_type varchar2<4000>
journey_date varchar2<4000>
arr_time varchar2<4000>
dept_time varchar2<4000>
source varchar2<4000>
destination varchar2<4000>
ticket_price number(5,2)
b_point varchar2<4000>
d_point varchar2<4000>
I am getting this error

ORA 0:01008: Not all variables bound
CHill60 24-Jul-13 7:20am    
I think you meant this comment for woopsydoozy as you've used the syntax he suggested not mine. I personally haven't used bound variables like this so I won't be much help going forward - you could try cmd.BindByName = true; first though

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900