Data are missing after updating

放肆的年华 提交于 2019-12-24 08:00:04

问题


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

Second, The image below shows the MobileInfo gridview under MobileINfo.aspx

Third, now we are going to edit the record in this page MobileInfo.aspx

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

Fifth and last, I went back in PersonalInfo.aspx but it gives me this...Data has been deleted

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:


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.



来源:https://stackoverflow.com/questions/14594513/data-are-missing-after-updating

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!