ASP.NET UpdateCommand replace E_UID with U_UID

时间:2015-07-28 15:47:42

标签: sql asp.net

I know this is simply a SQL question but I can't remember in ASP.NET how to make this work, keep getting UID column not there error.

want to get the value of UsersDataTbl.UID and UPDATE EnrollmentsTbl.UID

<asp:GridView ID="GridView3" runat="server" AllowSorting="True" AutoGenerateColumns="True" 
    BackColor="White" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CellPadding="3" 
    DataKeyNames="AutoNum" DataSourceID="AccessDataSource3" ForeColor="Black" GridLines="Vertical" 
    AutoGenerateEditButton="true" AutoGenerateDeleteButton="false">
    <FooterStyle BackColor="#CCCCCC" />
    <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
    <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
    <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
    <AlternatingRowStyle BackColor="#6699CC" />
</asp:GridView>

<asp:AccessDataSource ID="AccessDataSource3" runat="server" 
    DataFile="<%$ ConnectionStrings:AccessSubSiteString %>"
    DeleteCommand="DELETE FROM [EnrollmentsTbl] WHERE [AutoNum] = ?" 
    SelectCommand="SELECT EnrollmentsTbl.AutoNum, EnrollmentsTbl.UID As E_UID, UsersDataTbl.UID As U_UID, 
    UsersDataTbl.LastName, UsersDataTbl.FirstName FROM EnrollmentsTbl INNER JOIN UsersDataTbl 
    ON EnrollmentsTbl.UserName = UsersDataTbl.UserName"
    UpdateCommand="UPDATE [EnrollmentsTbl] SET E_UID = ?  WHERE [AutoNum] = ?">
    <DeleteParameters>
        <asp:Parameter Name="AutoNum" Type="Int32" />
    </DeleteParameters>
    <UpdateParameters>
        <asp:Parameter Name="E_UID" Type="Int32" />
        <asp:Parameter Name="AutoNum" Type="Int32" />
    </UpdateParameters>
</asp:AccessDataSource>

the error I get is: Exception Details: System.Data.OleDb.OleDbException: Cannot update 'E_UID'; field not updateable.

0 个答案:

没有答案