0

我正在尝试通过 griview 更新 mysql 数据库,但是当我单击更新按钮时,这里没有更改是我的 sql 数据源代码,但这不起作用

 <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:GisConnectionString %>"
            ProviderName="<%$ ConnectionStrings:GisConnectionString.ProviderName %>" SelectCommand="SELECT vehicleno, cnic, isaccepted, gname, fname, haulagecode FROM gis.registration WHERE (regno = ?)&#13;&#10;and vehicleno=?"
            UpdateCommand="UPDATE gis.registration SET vehicleno =?, cnic =?, isaccepted =?, gname =?, fname = ?, haulagecode = ?&#13;&#10;where regno=?&#13;&#10;and vehicleno=?">
            <SelectParameters>
                <asp:ControlParameter ControlID="TextBox1" Name="?" PropertyName="Text" />
                <asp:ControlParameter ControlID="TextBox2" Name="?" PropertyName="Text" />
            </SelectParameters>
            <UpdateParameters>
                <asp:Parameter Name="vehicleno" DbType="string" />
                <asp:Parameter Name="cnic" DbType="string"/>
                <asp:Parameter Name="isaccepted" DbType="string" />
                <asp:Parameter Name="gname" DbType="string"/>
                <asp:Parameter Name="fname" DbType="string"/>
                <asp:Parameter Name="haulagecode" DbType="string"/>
                <asp:Parameter Name="regno" DbType="string"/>
                <asp:Parameter Name="vehicleno" DbType="string"/>
            </UpdateParameters>
        </asp:SqlDataSource>

任何帮助将不胜感激提前感谢

4

1 回答 1

0

这是解决方案

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:GisConnectionString %>"
    ProviderName="<%$ ConnectionStrings:GisConnectionString.ProviderName %>" SelectCommand="SELECT vehicleno, cnic, isaccepted, gname, fname, haulagecode FROM gis.registration WHERE (regno = IFNULL(?, regno)) AND (companycode = ?)"
    UpdateCommand="UPDATE gis.registration SET vehicleno =?, cnic =?, isaccepted =?, gname =?, fname = ?, haulagecode = ? where regno=?">
    <SelectParameters>
        <asp:ControlParameter ControlID="TextBox1" Name="?" PropertyName="Text" />
        <asp:ControlParameter ControlID="Label1" Name="?" PropertyName="Text" />
    </SelectParameters>
    <UpdateParameters>
        <asp:Parameter Name="vehicleno" DbType="String" />
        <asp:Parameter Name="cnic" DbType="String"/>
        <asp:Parameter Name="isaccepted" DbType="String" />
        <asp:Parameter Name="gname" DbType="String"/>
        <asp:Parameter Name="fname" DbType="String"/>
        <asp:Parameter Name="haulagecode" DbType="String"/>
        <asp:ControlParameter ControlID="TextBox1" DbType="String" Name="regno" PropertyName="Text" />
        <asp:Parameter Name="vehicleno" DbType="String"/>
    </UpdateParameters>
</asp:SqlDataSource>
于 2012-06-09T07:29:21.497 回答