Updating to a database from a detailsview template field

02 Dec

Add Product And Return New Product IDValue ( @Product Name nvarchar(40), @Category ID int, @Unit Price money, @Discontinued bit, ) AS -- Insert the record into the database INSERT INTO Products(Product Name, Category ID, Unit Price, Discontinued) VALUES (@Product Name, @Category ID, @Unit Price, @Discontinued) -- Read the just-inserted Product ID into @New Product ID SET @New Product ID = SCOPE_IDENTITY() Protected Sub Add Product Data Source_Inserted(By Val sender As Object, By Val e As System. In future installments of this article series we will take a similar in-depth look at updating and deleting. This article is one in a series of articles on ASP.

For more information on the Details View control, see "Enhancing the ASP. I want to do an Insert/Cancel operation using a Details View control on a Web page.

updating to a database from a detailsview template field-60updating to a database from a detailsview template field-53updating to a database from a detailsview template field-12

The net result is that a new record is inserted into the database without writing a lick of code and without having to manually map the Sql Data Source's Insert Parameters to their sources (since the Details View does this for us automatically when Insert is clicked).

Here you can specify the A number of new data Web controls were introduced with ASP. These include the Grid View, Details View, and Form View, among others.

The Details View and Form View controls display information about one record at a time (unlike the Grid View, which displays information about a set of records).

Most database tables provide some mechanism to uniquely identify each record. This new product's Product ID value is ...", Product Name.

There are a variety of approaches, but a very common one is the use of an column is one whose value is automatically assigned by the database system when a new record is added to the table. Value) 'Display confirmation message New Product Added Msg. Text, new Product ID) End Sub In this article we looked at how to use the Sql Data Source to insert data into a database.