2014-09-28 70 views
1

當談到ASP.NET編碼時,我是一個新手,所以請原諒我,如果我失去了明顯的東西。ORA-01006:綁定變量不存在ASP.NET

我正在寫一個數據輸入頁面,其中我有一個FormView設置爲默認插入來處理插入和我有一個GridView查看錶中的數據,並允許編輯。

GridView的編輯工作完美,但FormView讓我失望。 當我在FormView中點擊插入時,我得到一個ORA-01006:綁定變量不存在。

我正在使用的SQLDataSource指向Oracle數據庫。

我FormView控件的代碼是:

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

我的SqlDataSource是:

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

我不知道這是否是因爲我沒有正確鏈接FormView的參數?

我希望有人能夠解釋我的問題?

親切的問候

湯姆

回答

0

什麼ORA-01006 : bind variable does not exist錯誤意味着是在某處你的代碼parametrised SQL語句正在建設中,但隨後你撥打的說法你沒有經過足夠的或傳遞到許多參數。

尋找更加緊密我可以看到你的

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

沒有參數
它應該是這個樣子:

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

Oracle documentation

一個程序發出BIND需要一個未在中列出的變量關聯的SQL語句。只有在SQL語句中以 冒號(:)或與號(&)作爲前綴的變量可以在 BIND調用OBIND或OBINDN中引用。此錯誤也可能是由預編譯器程序與相關庫 SQLLIB之間的 不匹配造成的。