accessdatasouce1.update using VB code in Asp.net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ashrafedes
    New Member
    • Jul 2008
    • 2

    accessdatasouce1.update using VB code in Asp.net

    Dear Mr

    I have problem , I add Button in Edit templete in form view1 and I put command accessdatasouce 1.update . I find it is not working

    I found No update happend and also No error I get it , I expect the command should be run from Accessdatasouce updatecommand specified in Aspx

    please need your help , what is the missing ?

    See the real code



    ASPX code
    Code:
     <asp:AccessDataSource ID="AccessDataSource1" runat="server" 
                DataFile="~/App_Data/DB.accdb" 
                DeleteCommand="DELETE FROM [cargo] WHERE [código] = ?" 
                InsertCommand="INSERT INTO [cargo] ([código], [cargo]) VALUES (?, ?)" 
                SelectCommand="SELECT * FROM [cargo]" 
                UpdateCommand="UPDATE [cargo] SET [cargo] = ? WHERE [código] = ?">
                <DeleteParameters>
                    <asp:Parameter Name="código" Type="Int32" />
                </DeleteParameters>
                <InsertParameters>
                    <asp:Parameter Name="código" Type="Int32" />
                    <asp:Parameter Name="cargo" Type="String" />
                </InsertParameters>
                <UpdateParameters>
                    <asp:Parameter Name="cargo" Type="String" />
                    <asp:Parameter Name="código" Type="Int32" />
                </UpdateParameters>
            </asp:AccessDataSource>
            <asp:FormView ID="FormView1" runat="server" DataKeyNames="código" 
                DataSourceID="AccessDataSource1">
                <EditItemTemplate>
                    código:
                    <asp:Label ID="códigoLabel1" runat="server" Text='<%# Eval("código") %>' />
                    <br />
                    cargo:
                    <asp:TextBox ID="cargoTextBox" runat="server" Text='<%# Bind("cargo") %>' />
                    <br />
                    <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" 
                        CommandName="Update" Text="Update" />
                    &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" 
                        CausesValidation="False" CommandName="Cancel" Text="Cancel" />
                    &nbsp;<asp:Button ID="Button1" runat="server" onclick="Button1_Click" 
                        Text="Button" />
                </EditItemTemplate>
                <InsertItemTemplate>
                    cargo:
                    <asp:TextBox ID="cargoTextBox" runat="server" Text='<%# Bind("cargo") %>' />
                    <br />
                    <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
                        CommandName="Insert" Text="Insert" />
                    &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" 
                        CausesValidation="False" CommandName="Cancel" Text="Cancel" />
                </InsertItemTemplate>
                <ItemTemplate>
                    código:
                    <asp:Label ID="códigoLabel" runat="server" Text='<%# Eval("código") %>' />
                    <br />
                    cargo:
                    <asp:Label ID="cargoLabel" runat="server" Text='<%# Bind("cargo") %>' />
                    <br />
                    <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" 
                        CommandName="Edit" Text="Edit" />
                    &nbsp;<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" 
                        CommandName="Delete" Text="Delete" />
                    &nbsp;<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" 
                        CommandName="New" Text="New" />
                </ItemTemplate>
            </asp:FormView>


    VB :
    Code:
        Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
            AccessDataSource1.Update()
            FormView1.ChangeMode(FormViewMode.ReadOnly)
     
        End Sub
    Attached Files
    Last edited by Frinavale; Nov 4 '11, 05:28 PM. Reason: Added code tags.
Working...