This is a series of blog posts, the last article. Also for beginners, I hope you can have better, more on the net-oriented programming understanding and understanding.
In the previous article, "ASP. NET development, from layers two to three, to object-oriented (4) http://www.cnblogs.com/insus/p/3837898.html, Insus.net lets you know that there is no need to write SQL statements, just pass in the fields, or values, or conditions, although some examples are listed, but can be left to play and expand.
Insus.net in the third article "ASP." NET development, from layer two to layer three to object-oriented (3) http://www.cnblogs.com/insus/p/3826706.html, also implements the parameters associated with SQL Server and stored procedure class BizBaseSQLSp.cs.
This is to implement the application for this category, because netizens come to the information to talk about whether there is an example of how to use this class. Starting from the very basics. Create a table in the database, and then add, edit, update, or delete operations for the table.
In order to demonstrate all the public methods or functions of this class as much as possible, insus.net is described in detail.
First develop the database and create a table [dbo]. [Employee], three fields were designed. The primary key field is [WORK_NBR], the data type is nvarchar, and the character is stored.
Create a stored procedure [dbo] that adds data. [Usp_employee_insert]:
Pass in three parameters, in the body code, the first to determine whether the primary key exists, if not present, to add records.
Create a stored procedure [dbo]. [Usp_employee_getall], is the record that gets all the tables:
Create a deleted stored procedure [dbo]. [Usp_employee_delete], delete record:
Create a stored procedure [dbo] with a conditional fetch of a field value for a record. [Usp_employee_getnamebynumber] to get the scalar value by passing in the primary key.
The following stored procedure [dbo]. [Usp_employee_isexisting] is a condition that determines whether a record has been stored in a table:
Delete the stored procedure for the record [dbo]. [Usp_employee_delete]:
The last stored procedure, which is the updated stored procedure [dbo]. [Usp_employee_update]
Designed the database, plus the last written "ASP." NET development, from layer two to layer three to object-oriented (3) http://www.cnblogs.com/insus/p/3826706.html, also implements the parameters associated with SQL Server and stored procedure class BizBaseSQLSp.cs. We can use this logic to create an object, the name of the object, usually named after the data table name, in the database, each table can implement an object.
Layered development, some people design and develop the database, some people develop the logic layer of each object. Here is the front page. Create an ASPX Web page. The ability to add records to a Web page implementation:
Implement the Buttonadd_click event in. Aspx.cs:
Next, implement the data that renders the data table, that is, the record that the user adds, in the Web page, pull a GridView control:
Background binding GridView Control:
To continue writing, we need to implement a Delete record function, that is, in the GridView control, click Delete, can delete the record that the GridView clicked. In the GridView control, add the following highlighted part of the HTML markup:
Now, we implement the removal program in. Aspx.cs:
Look at the effect you just implemented, whether there are exceptions or errors:
In order to be able to apply other methods or functions to BIZBASESQLSP, add a text box below, enter the work number, and get the employee name of the work number pair:
Here is the Buttonget_click event program, which obtains scalar scalars values:
Whether it is the front-end JavaScript or background development, is a function, an event, corresponding to the implementation. Distinguish between objects and ideas.
Another real function, is to use SqlDataReader to determine whether the record has been saved, in fact, when adding records, insus.net write to the stored procedure, you can step to steps, first to determine whether there is storage, if there is, return.
This is just HTML markup, you need to write the Button1_Click event in order to make this feature lively:
Take a look at this feature's real-time demo operation:
Just write it down here. For editing and updating, Insus.net has written a stored procedure to play your hands-on ability.