0 Replies - 5290 Views - Last Post: 14 June 2012 - 02:29 PM Rate Topic: -----

#1 ngrosh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 09-September 11

Update Command with AccessDataSource not working

Posted 14 June 2012 - 02:29 PM

Having a lot of trouble trying to get the update command to work. With the databound controls when I try to update I don't get any response. I also tried to see if I could update with direct inputs in the update command.. but found that only half of my columns were updated and the data wasn't even assigned to the correct columns so I'm not really sure whats going on ;/.

data source and update command code

   <asp:AccessDataSource ID="AccessDataSource1" runat="server" 
                        DeleteCommand="DELETE FROM [Customer] WHERE [Customer_ID] = ?" 
                        InsertCommand="INSERT INTO [Customer] ([Customer_ID], [Customer__First_Name], [Customer_Last_Name], [Customer_Address], [Customer_City], [Customer_State], [Customer_Zip], [Customer_Phone], [Customer_Email]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)" 
                        SelectCommand="SELECT * FROM [Customer]" 
                        UpdateCommand="UPDATE [Customer] SET [Customer__First_Name] = @Customer_First_Name, [Customer_Last_Name] = @Customer_Last_Name, [Customer_Address] = @Customer_Address, [Customer_City] = @Customer_City, [Customer_Zip] = @Customer_Zip, [Customer_Phone] = @Customer_Phone, [Customer_Email] = @Customer_Email WHERE [Customer_ID] = @Customer_ID">
                            <asp:Parameter Name="Customer_ID" Type="Int32" />
                            <asp:ControlParameter ControlID="txtFirstName" Name="Customer_First_Name" 
                                PropertyName="Text" Type="String" />
                            <asp:ControlParameter ControlID="txtLastName" Name="@Customer_Last_Name" 
                                PropertyName="Text" Type="String" />
                            <asp:ControlParameter ControlID="txtAddress" Name="@Customer_Address" 
                                PropertyName="Text" Type="String" />
                            <asp:ControlParameter ControlID="txtCity" Name="@Customer_City" 
                                PropertyName="Text" Type="String" />
                            <asp:ControlParameter ControlID="txtZip" Name="@Customer_Zip" 
                                PropertyName="Text" Type="String" />
                            <asp:ControlParameter ControlID="txtPhoneNumber" Name="@Customer_Phone" 
                                PropertyName="Text" Type="String" />
                            <asp:ControlParameter ControlID="txtEmail" Name="@Customer_Email" 
                                PropertyName="Text" Type="String" />
                            <asp:Parameter DefaultValue="1" Name="@Customer_ID" Type="Int32" />
                            <asp:Parameter Name="Customer_ID" Type="Int32" />
                            <asp:Parameter Name="Customer_First_Name" Type="String" />
                            <asp:Parameter Name="Customer_Last_Name" Type="String" />
                            <asp:Parameter Name="Customer_Address" Type="String" />
                            <asp:Parameter Name="Customer_City" Type="String" />
                            <asp:Parameter Name="Customer_State" Type="String" />
                            <asp:Parameter Name="Customer_Zip" Type="String" />
                            <asp:Parameter Name="Customer_Phone" Type="String" />
                            <asp:Parameter Name="Customer_Email" Type="String" />

code behind
Imports System.Data

Partial Class CustomerInformation
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim dv As DataView = DirectCast(AccessDataSource1.Select(DataSourceSelectArguments.Empty), DataView)

        For Each drv As DataRowView In dv
            txtAddress.Text = drv("Customer_Address").ToString()
            txtCity.Text = drv("Customer_City").ToString
            txtFirstName.Text = drv("Customer__First_Name").ToString
            txtLastName.Text = drv("Customer_Last_Name").ToString
            txtEmail.Text = drv("Customer_Email").ToString
            txtPhoneNumber.Text = drv("Customer_Phone").ToString
            txtZip.Text = drv("Customer_Zip").ToString


    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    End Sub
End Class

full code

Is This A Good Question/Topic? 0
  • +

Page 1 of 1