Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ORA-01006 : bind variable does not exist ASP.NET

I'm a newbie when it comes to ASP.NET coding, so please forgive me if I'm missing something obvious.

I'm writing a data input page, where I've got a FormView set to default to insert to handle the inserting and I have a gridview to view the data in the table and to allow editing.

The gridview's edit works perfectly, however the FormView is letting me down. When I hit the insert within the FormView I get an ORA-01006 : bind variable does not exist.

The SQLDataSource that I'm using is pointing to an Oracle DB.

My FormView code is :

<asp:FormView ID="FormView1" runat="server" CellPadding="4" DataKeyNames="DATAKEY" DataSourceID="Oracle" DefaultMode="Insert" ForeColor="#333333" HorizontalAlign="Left">

        <EditRowStyle BackColor="#999999" />
        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <InsertItemTemplate>
         <table>
         <tr>
             <td align="center">Year :</td>
             <td width="30px"><asp:TextBox ID="YearTextBox" runat="server" Text='<%# Bind("YEAR") %>'></asp:TextBox><br /></td>
         </tr>
          <tr>
             <td align="center">Week :</td>
             <td width="30px"><asp:TextBox ID="WeekTextBox" runat="server" Text='<%# Bind("WEEK") %>'></asp:TextBox><br /></td>
         </tr>
          <tr>
             <td align="center">Store :</td>
             <td width="30px"><asp:TextBox ID="StoreTextBox" runat="server" Text='<%# Bind("LOC_LOC_ID") %>'></asp:TextBox><br /></td>
         </tr>
         <tr>
             <td align="center">Brand :</td>
             <td width="30px"><asp:TextBox ID="BrandTextBox" runat="server" Text='<%# Bind("BRAND") %>'></asp:TextBox><br /></td>
         </tr>
          <tr>
             <td align="center">CO_WK_PERC :</td>
             <td width="30px"><asp:TextBox ID="CoWkPercTextBox" runat="server" Text='<%# Bind("CO_WK_PERC") %>'></asp:TextBox><br /></td>
         </tr>
          <tr>
             <td align="center">CO_STD_PERC :</td>
             <td width="30px"><asp:TextBox ID="CoStdPercTextBox" runat="server" Text='<%# Bind("CO_STD_PERC") %>'></asp:TextBox><br /></td>
         </tr>
          <tr>
             <td align="center">INT_WK_PERC :</td>
             <td width="30px"><asp:TextBox ID="IntWkPercTextBox" runat="server" Text='<%# Bind("INT_WK_PERC") %>'></asp:TextBox><br /></td>
         </tr>
          <tr>
             <td align="center">INT_STD_PERC :</td>
             <td width="30px"><asp:TextBox ID="IntStdPercTextBox" runat="server" Text='<%# Bind("INT_STD_PERC") %>' Enabled='<%# Bind("INT_STD_PERC") %>'></asp:TextBox><br /></td>
         </tr>
         </table>
            <div class="auto-style1">
                <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert" Text="Insert" />
                &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" />
            </div>
        </InsertItemTemplate>

        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
    </asp:FormView>

My SQLDataSource is :

<asp:SqlDataSource ID="Oracle" 
        runat="server" 
        ConnectionString="<%$ ConnectionStrings:ORACLE_IISUSER %>" 
        DeleteCommand="DELETE FROM &quot;RGP_PLAN_PERC_TEST_BK&quot; WHERE &quot;DATAKEY&quot; = ?" 
        InsertCommand="INSERT INTO &quot;RGP_PLAN_PERC_TEST_BK&quot; (&quot;YEAR&quot;, &quot;WEEK&quot;, &quot;BRAND&quot;, &quot;CO_WK_PERC&quot;, &quot;CO_STD_PERC&quot;, &quot;INT_WK_PERC&quot;, &quot;INT_STD_PERC&quot;, &quot;LOC_LOC_ID&quot;, &quot;DATAKEY&quot;) VALUES (:YEAR, :WEEK, :BRAND, :CO_WK_PERC, :CO_STD_PERC, :INT_WK_PERC, :INT_STD_PERC, :LOC_LOC_ID, (SELECT (MAX(DATAKEY) +1) FROM RGP_PLAN_PERC_TEST_BK) )" 
        ProviderName="<%$ ConnectionStrings:ORACLE_IISUSER.ProviderName %>" 
        SelectCommand="SELECT * FROM &quot;RGP_PLAN_PERC_TEST_BK&quot; ORDER BY &quot;YEAR&quot; DESC, &quot;WEEK&quot; DESC, &quot;LOC_LOC_ID&quot;" 
        UpdateCommand="UPDATE &quot;RGP_PLAN_PERC_TEST_BK&quot; SET &quot;YEAR&quot; = :YEAR, &quot;WEEK&quot; = :WEEK, &quot;BRAND&quot; = :BRAND, &quot;CO_WK_PERC&quot; = :CO_WK_PERC, &quot;CO_STD_PERC&quot; = :CO_STD_PERC, &quot;INT_WK_PERC&quot; = :INT_WK_PERC, &quot;INT_STD_PERC&quot; = :INT_STD_PERC, &quot;LOC_LOC_ID&quot; = :LOC_LOC_ID WHERE &quot;DATAKEY&quot; = :DATAKEY" OnSelecting="Oracle_Selecting">
        <DeleteParameters>
            <asp:Parameter Name="DATAKEY" Type="Decimal" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="YEAR" Type="String" />
            <asp:Parameter Name="WEEK" Type="String" />
            <asp:Parameter Name="BRAND" Type="String" />
            <asp:Parameter Name="CO_WK_PERC" Type="Decimal" />
            <asp:Parameter Name="CO_STD_PERC" Type="Decimal" />
            <asp:Parameter Name="INT_WK_PERC" Type="Decimal" />
            <asp:Parameter Name="INT_STD_PERC" Type="Decimal" />
            <asp:Parameter Name="LOC_LOC_ID" Type="String" />
            <asp:Parameter Name="DATAKEY" Type="Decimal" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="YEAR" Type="String" />
            <asp:Parameter Name="WEEK" Type="String" />
            <asp:Parameter Name="BRAND" Type="String" />
            <asp:Parameter Name="CO_WK_PERC" Type="Decimal" />
            <asp:Parameter Name="CO_STD_PERC" Type="Decimal" />
            <asp:Parameter Name="INT_WK_PERC" Type="Decimal" />
            <asp:Parameter Name="INT_STD_PERC" Type="Decimal" />
            <asp:Parameter Name="LOC_LOC_ID" Type="String" />
            <asp:Parameter Name="DATAKEY" Type="Decimal" />
        </UpdateParameters>
    </asp:SqlDataSource>

I'm not sure if it's because I haven't linked the FormView parameters correctly?

I'm hoping someone can shed some light on my issue?

Kind Regards

Tom

like image 736
killercantom Avatar asked Feb 18 '26 16:02

killercantom


1 Answers

What ORA-01006 : bind variable does not exist error means is somewhere in your code parametrised SQL statement is being constructed, but then you are calling that statement you are not passing enough or passing to many parameters.

looking more closely I can see that your

DeleteCommand="DELETE FROM &quot;RGP_PLAN_PERC_TEST_BK&quot; WHERE &quot;DATAKEY&quot; = ?" 

does not have parameter
it should look something like:

DeleteCommand="DELETE FROM &quot;RGP_PLAN_PERC_TEST_BK&quot; WHERE &quot;DATAKEY&quot; = :DATAKEY" 

Oracle documentation:

A program issued a BIND call for a variable not listed in the associated SQL statement. Only those variables prefixed by either a colon (:) or ampersand (&) in the SQL statement may be referenced in a BIND call, OBIND or OBINDN. This error may also be caused by a mismatch between a Precompiler program and the related library, SQLLIB.

like image 146
Matas Vaitkevicius Avatar answered Feb 20 '26 05:02

Matas Vaitkevicius



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!