gpt4 book ai didi

c# - ORA-01006 : bind variable does not exist ASP. 网络

转载 作者:行者123 更新时间:2023-11-30 16:57:47 25 4
gpt4 key购买 nike

我是 ASP.NET 编码方面的新手,所以如果我遗漏了一些明显的东西,请原谅我。

我正在编写一个数据输入页面,其中我有一个 FormView 设置为默认插入以处理插入,我有一个 gridview 来查看表中的数据并允许编辑。

gridview 的编辑工作完美,但是 FormView 让我失望。当我在 FormView 中点击插入时,我得到一个 ORA-01006:绑定(bind)变量不存在。

我正在使用的 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的参数?

我希望有人能阐明我的问题吗?

亲切的问候

汤姆

最佳答案

ORA-01006 : bind variable does not exist 错误意味着在你的代码中某处正在构建参数化的 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 :

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.

关于c# - ORA-01006 : bind variable does not exist ASP. 网络,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26089904/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com