问题与删除按钮

时间:2019-03-15 20:03:01

标签: sql asp.net visual-studio-2012

因此,我有一个连接到SQL数据库的内部网页。由于某种原因,我遇到了一个问题,其中删除按钮实际上并未发挥作用,我有点困惑。我猜我的删除查询可能不正确。这是我正在开发的一个继承网站,因此这使得了解为什么某些事情正在发生变得更加困难。。。。。。。。。。。

  <   <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="CodeId" DataSourceID="SqlDataSourceDetails" Height="50px" Width="125px" style="margin-bottom: 0px">
    <Fields>
        <asp:BoundField DataField="CodeId" HeaderText="CodeId" InsertVisible="False" Visible="false" ReadOnly="True" SortExpression="CodeId" />
        <asp:BoundField DataField="CodeDefinition" HeaderText="CodeDefinition" SortExpression="CodeDefinition" />
        <asp:BoundField DataField="Notes" HeaderText="Notes" SortExpression="Notes" />
        <asp:CommandField ShowEditButton="True" ShowInsertButton="True" ShowDeleteButton="True" />
    </Fields>
</asp:DetailsView>asp:SqlDataSource ID="SqlDataSourceDetails" runat="server" ConnectionString="<%$ ConnectionStrings:PurchaseOrderConnectionString %>" InsertCommand="INSERT INTO ClassCode(CodeDefinition, Notes) VALUES (@CodeDefinition, @Notes)" SelectCommand="SELECT CodeId, CodeDefinition, Notes FROM ClassCode WHERE (CodeId = @CodeId)" UpdateCommand="UPDATE ClassCode SET CodeDefinition = @CodeDefinition, Notes = @Notes WHERE (CodeId = @CodeId)" DeleteCommand="DELETE FROM [ClassCode] WHERE [CodeId] = @original_CodeId AND (([CodeDefinition] = @original_CodeDefinition) OR ([CodeDefinition] IS NULL AND @original_CodeDefinition IS NULL)) AND (([Notes] = @original_Notes) OR ([Notes] IS NULL AND @original_Notes IS NULL))" OldValuesParameterFormatString="original_{0}">
    <DeleteParameters>
        <asp:Parameter Name="original_CodeId" Type="Int32" />
        <asp:Parameter Name="original_CodeDefinition" Type="Int32" />
        <asp:Parameter Name="original_Notes" Type="String" />
    </DeleteParameters>
    <InsertParameters>
        <asp:Parameter Name="CodeDefinition" />
        <asp:Parameter Name="Notes" />
    </InsertParameters>
    <SelectParameters>
        <asp:ControlParameter ControlID="GridView1" Name="CodeId" PropertyName="SelectedValue" />
    </SelectParameters>
    <UpdateParameters>
        <asp:Parameter Name="CodeDefinition" />
        <asp:Parameter Name="Notes" />
        <asp:Parameter Name="CodeId" />
    </UpdateParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSourceClassCode" runat="server" ConflictDetection="CompareAllValues" ConnectionString="<%$ ConnectionStrings:PurchaseOrderConnectionString %>" DeleteCommand="DELETE FROM [ClassCode] WHERE [CodeId] = @original_CodeId AND (([CodeDefinition] = @original_CodeDefinition) OR ([CodeDefinition] IS NULL AND @original_CodeDefinition IS NULL)) AND (([Notes] = @original_Notes) OR ([Notes] IS NULL AND @original_Notes IS NULL))" InsertCommand="INSERT INTO [ClassCode] ([CodeDefinition], [Notes]) VALUES (@CodeDefinition, @Notes)" OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT * FROM [ClassCode]" UpdateCommand="UPDATE [ClassCode] SET [CodeDefinition] = @CodeDefinition, [Notes] = @Notes WHERE [CodeId] = @original_CodeId AND (([CodeDefinition] = @original_CodeDefinition) OR ([CodeDefinition] IS NULL AND @original_CodeDefinition IS NULL)) AND (([Notes] = @original_Notes) OR ([Notes] IS NULL AND @original_Notes IS NULL))">
    <DeleteParameters>
        <asp:Parameter Name="original_CodeId" Type="Int32" />
        <asp:Parameter Name="original_CodeDefinition" Type="Int32" />
        <asp:Parameter Name="original_Notes" Type="String" />
    </DeleteParameters>
    <InsertParameters>
        <asp:Parameter Name="CodeDefinition" Type="Int32" />
        <asp:Parameter Name="Notes" Type="String" />
    </InsertParameters>
    <UpdateParameters>
        <asp:Parameter Name="CodeDefinition" Type="Int32" />
        <asp:Parameter Name="Notes" Type="String" />
        <asp:Parameter Name="original_CodeId" Type="Int32" />
        <asp:Parameter Name="original_CodeDefinition" Type="Int32" />
        <asp:Parameter Name="original_Notes" Type="String" />
    </UpdateParameters>
</asp:SqlDataSource>

enter image description here

我已经遇到了运行时代码和其他所有问题,但我将其修复并解决了。希望有人可以帮助我到达终点。

0 个答案:

没有答案