TAILIEUCHUNG - Professional ASP.NET 1.0 Special Edition- P17

Professional Special Edition- P17:Those of us who are Microsoft developers can't help but notice that .NET has received a fair amount of visibility over the last year or so. This is quite surprising considering that for most of this period, .NET has been in its early infancy and beta versions. I can't remember any unreleased product that has caused this much interest among developers. And that's really an important point, because ignoring all the hype and press, .NET really is a product for developers, providing a great foundation for building all types of applications | have carried out the operation in previous versions of ADO. And we can use INSERT and DELETE statements in exactly the same way as we used an UPDATE statement in this example. However it s often preferable to use a stored procedure defined within the data store to perform data updates. Stored procedures can provide a useful increase in performance hide the structure of a database table from inquisitive users and allow finer control over security permissions. The next example demonstrates how we can use a similar technique to that above with a stored procedure instead of a SQL statement. Using a Stored Procedure with a Command Object Using a stored procedure with a Command object is a fundamentally similar process to using a SQL statement as we discovered in the previous chapter when we were extracting data from a data store. The example Updating Data with a Stored Procedure shows how we can use a Command object to execute a stored procedure that updates the source data. The stored procedure named AddNewBook is created within the WroxBooks database by the SQL script we provide in the samples. It inserts a new row into the BookList table using values provided in parameters to the stored procedure and returns zero 0 if it succeeds in inserting the new row However to make the process repeatable when you are experimenting with the samples we ve added a rather unusual twist to the procedure one which is unlikely to be found in a real-world application . If we hadn t done this you would only be able to run the procedure once unless you manually deleted the row in the database or edited the procedure to insert a different row. What the procedure does is to first check to see if a book with the specified ISBN the primary key of the table already exists. If it does exist it deletes this row from the table instead - and returns minus one -1 as the result. This way you can run the page as many times as you wish The AddNewBook Stored Procedure The .

TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
141    9    0    15-08-2020
13    5    0    15-08-2020
TÀI LIỆU XEM NHIỀU
7113    8    0
387    3    0
TÀI LIỆU HOT
TÀI LIỆU LIÊN QUAN
6    6    0