在处理命令期间发生一个或多个错误。 ORA-00936:缺少表达

时间:2012-12-27 09:25:12

标签: asp.net oracle10g

我正在尝试执行插入但收到此错误: [例外:在处理命令期间发生了一个或多个错误。 ORA-00936:缺少表达式]

适用于选择查询。

table structure is as follow
database-oracle 10g
table name-investor_info

investor_id-number
first_name-varchar
lastname-varchar
age-number
location-varchar
contact_number-varchar
email-varchar
checked-number-number


public void insert_details(string fname,string lname, int age, string location, string contactnumber, string email)
    {
        int id = get_id()+1;
        int check=0;



        string query = "INSERT INTO INVESTOR_INFO (INVESTOR_ID,FIRST_NAME,LAST_NAME,AGE,LOCATION,CONTACT_NUMBER,EMAIL,CHECKED) VALUES (@val1,@val2,@val3,@val4,@val5,@val6,@val7,@val8);";

        try
        {
            conn.Open();
            OleDbCommand command1 = new OleDbCommand(query,conn);
            command1.Parameters.AddWithValue("@val1", id);
            command1.Parameters.AddWithValue("@val2", fname);
            command1.Parameters.AddWithValue("@val3", lname);
            command1.Parameters.AddWithValue("@val4", age);
            command1.Parameters.AddWithValue("@val5", location);
            command1.Parameters.AddWithValue("@val6", contactnumber);
            command1.Parameters.AddWithValue("@val7", email);
            command1.Parameters.AddWithValue("@val8", check);

            command1.CommandType = CommandType.Text;

            command1.ExecuteNonQuery();

           // conn.Close();
        }
        catch (Exception e)
        {
            throw new Exception(e.Message);
        }
        finally
        {
            conn.Close();
        }

    }//end of insert

3 个答案:

答案 0 :(得分:1)

删除字符串QUERY中的分号

应该是

string query = "INSERT INTO INVESTOR_INFO (INVESTOR_ID,FIRST_NAME,LAST_NAME,AGE,LOCATION,CONTACT_NUMBER,EMAIL,CHECKED) VALUES (@val1,@val2,@val3,@val4,@val5,@val6,@val7,@val8)";

答案 1 :(得分:0)

从字符串查询中删除分号,并尝试如下,

string query =“INSERT INTO INVESTOR_INFO(INVESTOR_ID,FIRST_NAME,LAST_NAME,AGE,LOCATION,CONTACT_NUMBER,EMAIL,CHECKED)VALUES(@ val1,@ val2,@ val3,@ val4,@ val5,@ val6,@ val7, @的Val8)“;

始终使用表名特定模式名称。(schemeName.tableName)

答案 2 :(得分:0)

我暂时没有使用过Oracle,但您是否尝试将@替换为:参数。请参阅以下术语:

http://msdn.microsoft.com/en-us/library/system.data.oracleclient.oraclecommand.parameters.aspx