在SqlDataSource的DeleteCommand中获取“ORA-01036:非法变量名称/编号”

时间:2015-01-15 16:06:37

标签: asp.net oracle gridview sqldatasource sql-delete

我有 GridView 。它连接到 SqlDataSource 。我的数据库是 Oracle

当我运行网页时, SELECT 命令有效,我看到列表中的项目。当我点击删除按钮时,出现此错误:

  

ORA-01036:非法变量名称/编号

这是我的GridView和SqlDataSource:

<telerik:RadAjaxPanel ID="ajaxMyLinks" runat="server" width="100%" LoadingPanelID="RadAjaxLoadingPanel1">
     <telerik:RadGrid ID="gridMyLinks" runat="server" DataSourceID="SqlDataSourceMyLinks" AllowAutomaticDeletes="True" AllowPaging="True" BackColor="White" BorderColor="White" PageSize="5" ShowHeader="False">
         <MasterTableView AutoGenerateColumns="False" DataSourceID="SqlDataSourceMyLinks" DataKeyNames="N_USER_LINK_ID">
             <Columns>
                 <telerik:GridHyperLinkColumn AllowSorting="False" DataNavigateUrlFields="V_LINK" DataNavigateUrlFormatString="{0}" DataTextField="V_LINK_TITLE" DataTextFormatString="{0}" FilterControlAltText="Filter column column" UniqueName="column" Target="_blank">
                 </telerik:GridHyperLinkColumn>
                 <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete" ImageUrl="Content/images/delete.png" UniqueName="column1">
                 </telerik:GridButtonColumn>
             </Columns>
         </MasterTableView>
         <PagerStyle Mode="NextPrev" ShowPagerText="False" />
     </telerik:RadGrid>
 </telerik:RadAjaxPanel>
<asp:SqlDataSource ID="SqlDataSourceMyLinks" runat="server" ConnectionString="<%$ ConnectionStrings:DefaultConnection %>" SelectCommand="SELECT V_LINK_TITLE, V_LINK, N_USER_LINK_ID FROM TAPP_IFH_USER_LINK WHERE (N_USER_ID = :USER_ID) ORDER BY N_USER_LINK_ID DESC" DeleteCommand="DELETE FROM TAPP_IFH_USER_LINK WHERE (N_USER_LINK_ID = :USER_LINK_ID)" ProviderName="<%$ ConnectionStrings:DefaultConnection.ProviderName %>">
  <DeleteParameters>
      <asp:Parameter Name="USER_LINK_ID" Type="Int32"></asp:Parameter>
  </DeleteParameters>
  <SelectParameters>
      <asp:SessionParameter Name="USER_ID" SessionField="USER_ID" />
  </SelectParameters>
</asp:SqlDataSource>

1 个答案:

答案 0 :(得分:1)

找到解决方案。 DB中的列名与参数之间的参数名称不匹配。参数名称为 USER_LINK_ID ,而列名称为 N_USER_LINK_ID

如果您的问题不是问题,请检查this post。它有更多的建议