简体   繁体   English

ORA-01036:在数据源上使用插入命令时

[英]ORA-01036: when using Insert command on datasource

Trying to set up an insert statement in asp.net. 试图在asp.net中设置一个插入语句。

My insertCommand is as follows: 我的insertCommand如下:

InsertCommand="INSERT INTO DVD VALUES (DVD_SEQ.NEXTVAL, :DVD_TITLE, :RENTAL_COST, :RATING, :COVER_IMAGE)" 

The code for the insert parameters are: 插入参数的代码为:

<InsertParameters>
    <asp:ControlParameter ControlID="titleBox" DefaultValue="TITLEDEFAULT" 
        Name="DVD_TITLE" PropertyName="Text" Type="String" />
    <asp:ControlParameter ControlID="rentalBox" DefaultValue="99" 
        Name="RENTAL_COST" PropertyName="Text" Type="String" />
    <asp:ControlParameter ControlID="ratingList" DefaultValue="25" Name="RATING" 
        PropertyName="SelectedValue" Type="Int32" />
    <asp:Parameter Name="COVER_IMAGE" Type="String" DefaultValue="0.jpg" />
    <asp:ControlParameter ControlID="genreList" Name="GENRE_ID" 
        PropertyName="SelectedValue" />
</InsertParameters>

And my OracleDB table (DVD) which is being inserted into is: 我插入的OracleDB表(DVD)是:

create table dvd
(
dvd_id integer primary key not null,
dvd_title char(100) not null,
rental_cost number(9,2) not null,
rating integer not null,
cover_image char(100),
foreign key(rating) references RATING(rating_id)
);

I'm thinking it's a potential conflict of variable types, as the types for the variables in the parameter section do differ from that in my table but I've tried swapping them around to more fitting types to no avail! 我认为这是变量类型的潜在冲突,因为参数部分中的变量类型确实与我的表中的变量类型不同,但是我尝试将它们换成更合适的类型,但无济于事!

ORA-01036: illegal variable name/number means that you're binding a variable that is not a part of the SQL query. ORA-01036: illegal variable name/number表示您要绑定的变量不是SQL查询的一部分。

In other words, you need to remove GENRE_ID from your InsertParameters (bound parameters) since it's not a part of the SQL and the error should go away. 换句话说,您需要从InsertParameters(绑定参数)中删除GENRE_ID ,因为它不是SQL的一部分,错误应该消失了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM