data source and update command code
<asp:AccessDataSource ID="AccessDataSource1" runat="server"
DataFile="~/App_Data/HandyManTaylor.mdb"
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">
<DeleteParameters>
<asp:Parameter Name="Customer_ID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<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" />
</UpdateParameters>
<InsertParameters>
<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" />
</InsertParameters>
</asp:AccessDataSource>
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
Next
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
AccessDataSource1.Update()
End Sub
End Class
full code
Spoiler

New Topic/Question
Reply



MultiQuote


|