<asp:SqlDataSource ConnectionString="<%$ ConnectionStrings:NorthwindOLEDB %>" ID="SqlDataSource1" ProviderName="<%$ ConnectionStrings:NorthwindOLEDB.ProviderName %>" runat="server" SelectCommand="SELECT TOP 10 [OrderID], [OrderDate], [ShipCountry] FROM [Orders]" UpdateCommand="UPDATE [Orders] SET [OrderDate] = ?, [ShipCountry] = ? WHERE [OrderID] = ?" OnUpdating="SqlDataSource1_Updating"> <UpdateParameters> <asp:Parameter Name="OrderDate" Type="DateTime" /> <asp:Parameter Name="ShipCountry" Type="String" /> <asp:Parameter Name="OrderID" Type="Int32" /> </UpdateParameters> </asp:SqlDataSource> |
Protected Sub SqlDataSource1_Updating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) e.Command.Parameters("@id").Value = e.Command.Parameters("@ContactID").Value e.Command.Parameters("@name").Value = e.Command.Parameters("@ContactName").Value e.Command.Parameters.Remove(e.Command.Parameters("@ContactID")) e.Command.Parameters.Remove(e.Command.Parameters("@ContactName")) End Sub <asp:SqlDataSource ConnectionString="<%$ ConnectionStrings:Contacts %>" ID="SqlDataSource1" runat="server" SelectCommand="SELECT [ContactID], [ContactName] FROM [Contacts]" UpdateCommand="UpdateContactName" UpdateCommandType="StoredProcedure" OnUpdating="SqlDataSource1_Updating"> <UpdateParameters> <asp:Parameter Name="id" Type="Int32" /> <asp:Parameter Name="name" Type="String" /> </UpdateParameters> </asp:SqlDataSource> |