locked
Update SET syntax error RRS feed

  • Question

  • User-2109039660 posted

    I have an update query that I cannot get to work, the fail messge is a syntax error in the sql statement. Is it because I'm trying to update different tables? or just malformed?

    Many thanks in advance

    UpdateCommand="UPDATE SET aspnet_Users.UserName = @UserName, tblUserProfiles.FirstName = @FirstName, tblUserProfiles.LastName = @LastName, aspnet_Roles.RoleName = @RoleName, tblUserProfiles.GalleryLink = @GalleryLink, aspnet_Membership.Email = @Email, aspnet_Membership.IsApproved = @IsApproved WHERE aspnet_Users.UserId = @UserId"


     

    This is the full code

                                                <asp:DetailsView AutoGenerateRows="False" DataSourceID="AccessDataSource3" DataKeyNames="UserId"
                                                    HeaderText="Member Details" ID="DetailsView1" runat="server" Width="400px" OnItemUpdated="DetailsView1_ItemUpdated"
                                                    OnItemInserted="DetailsView1_ItemInserted" OnDataBound="DetailsView1_DataBound"
                                                    GridLines="None" CellSpacing="4" Font-Bold="False">
                                                    <Fields>
                                                        <asp:BoundField DataField="UserName" HeaderText="User Name" SortExpression="UserName"
                                                            ItemStyle-ForeColor="White"></asp:BoundField>
                                                        <asp:BoundField DataField="FirstName" HeaderText="First Name" SortExpression="FirstName"
                                                            ItemStyle-ForeColor="White"></asp:BoundField>
                                                        <asp:BoundField DataField="LastName" HeaderText="Last Name" SortExpression="LastName"
                                                            ItemStyle-ForeColor="White"></asp:BoundField>
                                                        <asp:BoundField DataField="RoleName" HeaderText="Role" SortExpression="RoleName"
                                                            ItemStyle-ForeColor="White"></asp:BoundField>
                                                        <asp:BoundField DataField="GalleryLink" HeaderText="Gallery Link" SortExpression="GalleryLink"
                                                            ItemStyle-ForeColor="White"></asp:BoundField>
                                                        <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" ItemStyle-ForeColor="White">
                                                        </asp:BoundField>
                                                        <asp:CheckBoxField DataField="IsApproved" HeaderText="IsApproved" SortExpression="IsApproved"
                                                            ItemStyle-ForeColor="White"></asp:CheckBoxField>
                                                        <asp:CommandField ShowEditButton="True" EditText="Edit Member Details" />
                                                    </Fields>
                                                    <HeaderStyle ForeColor="#636363" Font-Bold="True" />
                                                </asp:DetailsView>
                                                <asp:AccessDataSource ID="AccessDataSource3" runat="server" DataFile="~/App_Data/ASPNetDB.mdb"
                                                    SelectCommand="SELECT aspnet_Users.UserId, aspnet_Users.UserName, tblUserProfiles.FirstName, tblUserProfiles.LastName, aspnet_Roles.RoleName, tblUserProfiles.GalleryLink, aspnet_Membership.Email, aspnet_Membership.IsApproved FROM ((((aspnet_Users INNER JOIN aspnet_Membership ON aspnet_Users.UserId = aspnet_Membership.UserId) INNER JOIN tblUserProfiles ON aspnet_Users.UserId = tblUserProfiles.UserId) INNER JOIN aspnet_UsersInRoles ON aspnet_Users.UserId = aspnet_UsersInRoles.UserId) INNER JOIN aspnet_Roles ON aspnet_UsersInRoles.RoleId = aspnet_Roles.RoleId) WHERE (aspnet_Users.UserId = @UserId)"
                                                    UpdateCommand="UPDATE SET aspnet_Users.UserName = @UserName, tblUserProfiles.FirstName = @FirstName, tblUserProfiles.LastName = @LastName, aspnet_Roles.RoleName = @RoleName, tblUserProfiles.GalleryLink = @GalleryLink, aspnet_Membership.Email = @Email, aspnet_Membership.IsApproved = @IsApproved WHERE aspnet_Users.UserId = @UserId">
                                                    <SelectParameters>
                                                        <asp:ControlParameter ControlID="DropDownList1" Name="UserId" PropertyName="SelectedValue"
                                                            Type="Int32" />
                                                    </SelectParameters>
                                                    <UpdateParameters>
                                                        <asp:Parameter Name="UserName" Type="String" />
                                                        <asp:Parameter Name="FirstName" Type="String" />
                                                        <asp:Parameter Name="LastName" Type="String" />
                                                        <asp:Parameter Name="RoleName" Type="String" />
                                                        <asp:Parameter Name="GalleryLink" Type="String" />
                                                        <asp:Parameter Name="Email" Type="String" />
                                                        <asp:Parameter Name="IsApproved" Type="Boolean" />
                                                    </UpdateParameters>
                                                </asp:AccessDataSource>

    Cheers Rob.

    Sunday, November 28, 2010 2:50 PM

Answers

  • User187056398 posted

    You need the table name in there:

    UPDATE MyTable SET 

    I don't think you can update multiple tables in one update statement.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, November 28, 2010 5:14 PM

All replies

  • User187056398 posted

    You need the table name in there:

    UPDATE MyTable SET 

    I don't think you can update multiple tables in one update statement.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, November 28, 2010 5:14 PM
  • User-2109039660 posted

    Thanks for the reply Steve, I did try that and yes that worked, although for only one table. I'll check on google to see if it can be done for multiple tables.

     

    Cheers Rob. 

    Monday, November 29, 2010 10:29 AM