Click here to Skip to main content
15,867,765 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi....

Is there any way to pass oracle sequence value as a parameter in sqldatasource insert operation?? Or there is some different way to do so? I am having ora-01036 error illegal value while running the following code:
C#
<asp:SqlDataSource ID="sqlcrud" runat="server"
           ConnectionString="<%$ ConnectionStrings:testconn %>"
           InsertCommand="INSERT INTO "PEOPLE" ("EMP_ID", "FNAME", "GENDER", "DEPT") VALUES (SEQ_PEOPLE.NEXTVAL, :FNAME, :GENDER, :DEPT)"
           ProviderName="<%$ ConnectionStrings:testconn.ProviderName %>"
           UpdateCommand="UPDATE "PEOPLE" SET "FNAME" = :FNAME, "GENDER" = :GENDER, "DEPT" = :DEPT WHERE "EMP_ID" = :EMP_ID">


code behind file:

C#
protected void linkinsert_Click(object sender, EventArgs e)
        {
            sqlcrud.InsertParameters["FNAME"].DefaultValue =
                ((TextBox)GridView1.FooterRow.FindControl("txtinsertname")).Text;

            sqlcrud.InsertParameters["GENDER"].DefaultValue =
               ((DropDownList)GridView1.FooterRow.FindControl("dropgenderinsert")).SelectedValue;

            sqlcrud.InsertParameters["DEPT"].DefaultValue =
               ((TextBox)GridView1.FooterRow.FindControl("txtinsertdept")).Text;

            sqlcrud.Insert();

        }

though the update command runs good, insert command is throwing the error..

Any help will be greatly appreciated.

Thank you...!!
Posted
Comments
Jörgen Andersson 25-Aug-15 3:31am    
Are you using System.Data.OracleClient or Oracle.DataAccess.Client?
planetz 26-Aug-15 0:58am    
i am using System.Data.OracleClient. Problem is now solved.

1 solution

it worked!!....
C#
<insertparameters>
               <%--<asp:parameter name="EMP_ID" type="Decimal" xmlns:asp="#unknown" />--%>
               <asp:parameter name="FNAME" type="String" xmlns:asp="#unknown" />
               <asp:parameter name="GENDER" type="String" xmlns:asp="#unknown" />
               <asp:parameter name="DEPT" type="String" xmlns:asp="#unknown" />
           </insertparameters>


I commented the EMP_ID parameter that was uncommented before... :)
 
Share this answer
 

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