Data are missing after updating

2019-08-01 12:40发布

Okay I'll discuss my problem with images so we can solve it easily. Hoping.

First, The image below shows the PersonalInfo gridview under PersonalInfo.aspx enter image description here

Second, The image below shows the MobileInfo gridview under MobileINfo.aspxenter image description here

Third, now we are going to edit the record in this page MobileInfo.aspxenter image description here

Fourth, Image below I thought everything works perfectly because the data has been updated. But...enter image description here

Fifth and last, I went back in PersonalInfo.aspx but it gives me this...Data has been deletedenter image description here

Here's my code for 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>

and Here's my code for 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>

I hope someone can help me here. Thanks.

1条回答
甜甜的少女心
2楼-- · 2019-08-01 13:08

What I see here is that you have the same UpdateCommand on the two pages, but on the second page that you make the update, the values are all null or not exist and the result is that you actually deletes them.

Go on this UpdateCommand of the page MobileINfo.aspx and remove the field that you do not actually use - keep only the one that you actually change them - or the rest are refereed to data that not exist and there fore they are delete.

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] = ?"

Eg, on the second page the LiscensedNumber exit, but the Gender not. After your update the Gender will update to null, or empty string.

查看更多
登录 后发表回答