请帮我解决oracle数据库错误 [英] Please help me to solve oracle database error

查看:91
本文介绍了请帮我解决oracle数据库错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在处理命令期间发生了一个或多个错误。

ORA-00936:缺少表达式



错误名称




表是test3,其中一个属性名称为varchar2(20)



编码是

"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

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;
}

推荐答案

2期:

1)我不知道@ 是用于识别Oracle中参数的有效字符

2)当您添加参数并指定名称时,请不要使用转义字符



更像这样:

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:
string s = "insert into test3(NAME) values(:nam)";






and

cmd.Parameters.AddWithValue("nam", country);


我认为OLEDb不支持命令中的命名参数...请尝试以下代码(警告 - 我的语法可能不会完美)

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


这篇关于请帮我解决oracle数据库错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆