1

好的,我将用图像讨论我的问题,以便我们轻松解决。希望。

首先,下图显示了 PersonalInfo.aspx 下的 PersonalInfo gridview 在此处输入图像描述

二、下图是MobileINfo.aspx下的MobileInfo gridview在此处输入图像描述

三、现在我们要编辑这个页面MobileInfo.aspx中的记录在此处输入图像描述

第四,下图我认为一切正常,因为数据已经更新。但...在此处输入图像描述

第五次也是最后一次,我回到 PersonalInfo.aspx 但它给了我这个...数据已被删除在此处输入图像描述

这是我的 PersonalInfo.aspx 代码

<asp:AccessDataSource runat="server" ID="AccessDataSource1" DeleteCommand="DELETE FROM [DriversRecords] WHERE [ID] = ?" InsertCommand="INSERT INTO [DriversRecords] ([Username], [Password], [FirstName], [LastName], [MiddleName], [Address], [Age], [Gender], [ContactNumber], [PlateNumber], [Color], [Brand], [LiscensedNumber], [SSSNumber], [TIN], [Type], [Model], [BirthDay], [BirthMonth], [BirthYear]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" UpdateCommand="UPDATE [DriversRecords] SET [Username] = ?, [Password] = ?, [FirstName] = ?, [LastName] = ?, [MiddleName] = ?, [Address] = ?, [Age] = ?, [Gender] = ?, [ContactNumber] = ?, [PlateNumber] = ?, [Color] = ?, [Brand] = ?, [LiscensedNumber] = ?, [SSSNumber] = ?, [TIN] = ?, [Type] = ?, [Model] = ?, [BirthDay] = ?, [BirthMonth] = ?, [BirthYear] = ? WHERE [ID] = ?" DataFile="_private/records.mdb" SelectCommand="SELECT * FROM [DriversRecords]">
            <DeleteParameters>
                <asp:parameter Name="ID" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:parameter Name="Username" Type="String" />
                <asp:parameter Name="Password" Type="String" />
                <asp:parameter Name="FirstName" Type="String" />
                <asp:parameter Name="LastName" Type="String" />
                <asp:parameter Name="MiddleName" Type="String" />
                <asp:parameter Name="Address" Type="String" />
                <asp:parameter Name="Age" Type="String" />
                <asp:parameter Name="Gender" Type="String" />
                <asp:parameter Name="ContactNumber" Type="String" />
                <asp:parameter Name="PlateNumber" Type="String" />
                <asp:parameter Name="Color" Type="String" />
                <asp:parameter Name="Brand" Type="String" />
                <asp:parameter Name="LiscensedNumber" Type="String" />
                <asp:parameter Name="SSSNumber" Type="String" />
                <asp:parameter Name="TIN" Type="String" />
                <asp:parameter Name="Type" Type="String" />
                <asp:parameter Name="Model" Type="String" />
                <asp:parameter Name="BirthDay" Type="String" />
                <asp:parameter Name="BirthMonth" Type="String" />
                <asp:parameter Name="BirthYear" Type="String" />
                <asp:parameter Name="ID" Type="Int32" />
            </UpdateParameters>
            <InsertParameters>
                <asp:parameter Name="Username" Type="String" />
                <asp:parameter Name="Password" Type="String" />
                <asp:parameter Name="FirstName" Type="String" />
                <asp:parameter Name="LastName" Type="String" />
                <asp:parameter Name="MiddleName" Type="String" />
                <asp:parameter Name="Address" Type="String" />
                <asp:parameter Name="Age" Type="String" />
                <asp:parameter Name="Gender" Type="String" />
                <asp:parameter Name="ContactNumber" Type="String" />
                <asp:parameter Name="PlateNumber" Type="String" />
                <asp:parameter Name="Color" Type="String" />
                <asp:parameter Name="Brand" Type="String" />
                <asp:parameter Name="LiscensedNumber" Type="String" />
                <asp:parameter Name="SSSNumber" Type="String" />
                <asp:parameter Name="TIN" Type="String" />
                <asp:parameter Name="Type" Type="String" />
                <asp:parameter Name="Model" Type="String" />
                <asp:parameter Name="BirthDay" Type="String" />
                <asp:parameter Name="BirthMonth" Type="String" />
                <asp:parameter Name="BirthYear" Type="String" />
            </InsertParameters>
        </asp:AccessDataSource>

这是我的 MobileInfo.aspx 代码

<asp:AccessDataSource runat="server" ID="AccessDataSource1" DeleteCommand="DELETE FROM [DriversRecords] WHERE [ID] = ?" InsertCommand="INSERT INTO [DriversRecords] ([Username], [Password], [FirstName], [LastName], [MiddleName], [Address], [Age], [Gender], [ContactNumber], [PlateNumber], [Color], [Brand], [LiscensedNumber], [SSSNumber], [TIN], [Type], [Model], [BirthDay], [BirthMonth], [BirthYear]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" UpdateCommand="UPDATE [DriversRecords] SET [Username] = ?, [Password] = ?, [FirstName] = ?, [LastName] = ?, [MiddleName] = ?, [Address] = ?, [Age] = ?, [Gender] = ?, [ContactNumber] = ?, [PlateNumber] = ?, [Color] = ?, [Brand] = ?, [LiscensedNumber] = ?, [SSSNumber] = ?, [TIN] = ?, [Type] = ?, [Model] = ?, [BirthDay] = ?, [BirthMonth] = ?, [BirthYear] = ? WHERE [ID] = ?" DataFile="_private/records.mdb" SelectCommand="SELECT * FROM [DriversRecords]">
            <DeleteParameters>
                <asp:parameter Name="ID" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:parameter Name="Username" Type="String" />
                <asp:parameter Name="Password" Type="String" />
                <asp:parameter Name="FirstName" Type="String" />
                <asp:parameter Name="LastName" Type="String" />
                <asp:parameter Name="MiddleName" Type="String" />
                <asp:parameter Name="Address" Type="String" />
                <asp:parameter Name="Age" Type="String" />
                <asp:parameter Name="Gender" Type="String" />
                <asp:parameter Name="ContactNumber" Type="String" />
                <asp:parameter Name="PlateNumber" Type="String" />
                <asp:parameter Name="Color" Type="String" />
                <asp:parameter Name="Brand" Type="String" />
                <asp:parameter Name="LiscensedNumber" Type="String" />
                <asp:parameter Name="SSSNumber" Type="String" />
                <asp:parameter Name="TIN" Type="String" />
                <asp:parameter Name="Type" Type="String" />
                <asp:parameter Name="Model" Type="String" />
                <asp:parameter Name="BirthDay" Type="String" />
                <asp:parameter Name="BirthMonth" Type="String" />
                <asp:parameter Name="BirthYear" Type="String" />
                <asp:parameter Name="ID" Type="Int32" />
            </UpdateParameters>
            <InsertParameters>
                <asp:parameter Name="Username" Type="String" />
                <asp:parameter Name="Password" Type="String" />
                <asp:parameter Name="FirstName" Type="String" />
                <asp:parameter Name="LastName" Type="String" />
                <asp:parameter Name="MiddleName" Type="String" />
                <asp:parameter Name="Address" Type="String" />
                <asp:parameter Name="Age" Type="String" />
                <asp:parameter Name="Gender" Type="String" />
                <asp:parameter Name="ContactNumber" Type="String" />
                <asp:parameter Name="PlateNumber" Type="String" />
                <asp:parameter Name="Color" Type="String" />
                <asp:parameter Name="Brand" Type="String" />
                <asp:parameter Name="LiscensedNumber" Type="String" />
                <asp:parameter Name="SSSNumber" Type="String" />
                <asp:parameter Name="TIN" Type="String" />
                <asp:parameter Name="Type" Type="String" />
                <asp:parameter Name="Model" Type="String" />
                <asp:parameter Name="BirthDay" Type="String" />
                <asp:parameter Name="BirthMonth" Type="String" />
                <asp:parameter Name="BirthYear" Type="String" />
            </InsertParameters>
        </asp:AccessDataSource>

我希望有人可以在这里帮助我。谢谢。

4

1 回答 1

1

我在这里看到的是您UpdateCommand在两个页面上具有相同的内容,但是在您进行更新的第二个页面上,这些值全部为空或不存在,结果是您实际上删除了它们。

继续页面的此 UpdateCommandMobileINfo.aspx并删除您实际上不使用的字段 - 仅保留您实际更改它们的字段 - 或者将其余部分引用到不存在的数据,因此它们被删除。

UpdateCommand="UPDATE [DriversRecords] SET [Username] = ?, [Password] = ?, [FirstName] = ?, [LastName] = ?, [MiddleName] = ?, [Address] = ?, [Age] = ?, [Gender] = ?, [ContactNumber] = ?, [PlateNumber] = ?, [Color] = ?, [Brand] = ?, [LiscensedNumber] = ?, [SSSNumber] = ?, [TIN] = ?, [Type] = ?, [Model] = ?, [BirthDay] = ?, [BirthMonth] = ?, [BirthYear] = ? WHERE [ID] = ?"

例如,在第二页LiscensedNumber退出,但Gender不是。更新后,性别将更新为 null 或空字符串。

于 2013-01-30T00:44:58.517 回答