简体   繁体   中英

ORA-01036: when using Insert command on datasource

Trying to set up an insert statement in asp.net.

My insertCommand is as follows:

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:

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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