Sqldatasource onupdating method the double your dating series

14 Jun

The following code example demonstrates how to retrieve data from Microsoft SQL Server, display it in a Grid View control, and use a Details View control to see details of a selected row in the Grid View and as a form to insert new records. I have a Transactions table which stores individual items that the user selects for purchase (item name, item price, order ID, etc) I have an Orders table which stores values for the Order (account name, order total, etc) Here is my Sql Data Source as defined in the page: " Insert Command="INSERT INTO [tbl Orders] ([Order Date], [Order Total], [Order Account], [Order Cost Centre]) VALUES (@Order Date, @Order Total, @Order Account, @Order Cost Centre); SELECT @Order New ID = SCOPE_IDENTITY()" Select Command="SELECT * FROM [tbl Orders]" Update Command="UPDATE [tbl Orders] SET [Order Date] = @Order Date, [Order Total] = @Order Total, [Order Account] = @Order Account, [Order Cost Centre] = @Order Cost Centre WHERE [Order ID] = @original_Order ID AND [Order Date] = @original_Order Date AND [Order Total] = @original_Order Total AND [Order Account] = @original_Order Account AND [Order Cost Centre] = @original_Order Cost Centre" Old Values Parameter Format String="original_" oninserting="Sql Data Source2_Inserting" oninserted="Sql Data Source2_Inserted" onupdated="Sql Data Source2_Updated" onupdating="Sql Data Source2_Updating" //Update Order Table with Total of Order //Sql Data Source2. Update(); The page doesn't error out, but the Update to Order Total in the Orders Db doesn't update. Or, tap into the Updating event, and add the new value to the event argument collection of values. providers that do not support named parameters in SQL statements and instead use the '? In those cases you should define parameters in the order specified in the associated SQL statement.events before it executes the SQL statement for the corresponding command property.

Parameters from a data-bound control include both values for the data operation and for key values to identify a specific row, as defined by the definitions to specify parameter order, parameter type, and parameter direction as well as additional parameters other than those based on fields bound to a control.An example of this would be an output parameter that returns a value automatically generated by the data source such as an auto-incrementing primary key or a date-time stamp.If you insert a record, the Details View automatically populates the collection with values from the bound columns and calls the Insert method.The Details View can infer the correct parameters from any Bound Field object and a parameter for the Template Field object when the ASP. In this example, an additional parameter is added in the On Inserting event handler to handle the primary key that is returned by the stored procedure.If you click the automatically generated Insert button of the Details View control, the Details View shows a different user interface, which is used to insert a new record.The example uses a stored procedure to insert records and returns the primary key of the inserted row.event to perform additional initialization operations that are specific to your application, to validate the values of parameters, or to change the parameter values before the Sql Data Source control performs the update operation.