I will not introduce the famous sqlhelper here. There are many applications, but there are few examples of getting started. I recently sorted out how to package it for free and provided it for you to download, it contains all the source code of the SQL database and sqlhelper (with detailed instructions ). Code Come here: 1 Protected Void Button#click ( Object Sender, eventargs E)
2 {
3 // Obtain the command to be executed
4 String Sqlexec = Textbox1.text;
5 Sqlcommand cmd = New Sqlcommand ();
6 // Defines the storage range of object Resources. Once the using range ends, the resources occupied by the other party are released.
7 Using (Sqlconnection Conn = New Sqlconnection (sqlhelper. connectionstringlocaltransaction ))
8 {
9 // Open connection (51aspx.com)
10 Conn. open ();
11 // Call the execution method. Because there is no parameter, the last item is directly set to null.
12 Sqlhelper. executenonquery (Conn, commandtype. storedprocedure, sqlexec, Null );
13 Response. Write ( " <Font color = Red> Operation complete! Check the database! </Font> " );
14 }
15 }
Sqlhelper is a very convenient database operation function. It has powerful functions and is very simple to use. It removes the need for a lot of complex database operation code. It has many applications in multi-tier applications and object-oriented development.
The sqlhelper source code is described in detail. The example contains the original example SQL statement of 51aspx.
The operations are as follows:
Simple SQL statement (excutesql)
Simple SQL statement with parameters (excutesqlparm)
Excuteproc)
Stored Procedure with parameters (excuteprocparm)
Returns only one field (excutescalar)
Response dataset (excutereader)
Source code:/files/liudao/51aspxsqlhelper_51aspx.rar
The database contains sample data and stored procedure updatetable \ updatetablebyparm. You can modify and test the data by yourself. Reprinted with the 51aspx author information. Thank you! For more information, see ~~
Many experts may think it is simple, but I still believe that sqlhelper will not be used in many cases. I hope it will help you!