1. method call for the start page on Layer 3
Response. Write (sqlhelper. Test (); // static method call response. Write (New sqlhelper (). Test (); // non-static method call
2. Press the tab key twice in a row to automatically display it.CodeExample:
After writing the switch, press the tab key twice in a row. The code and format will be automatically generated (in)
3. Simpler Method for closing a connection (the try-catch method can be replaced)
Using (SDR = cmd. executereader (commandbehavior. closeconnection) {DT. Load (SDR );}
Try-catch is written as follows:
Public int executenonquery (string plain text, commandtype CT) {int res; try {cmd = new sqlcommand (plain text, getconn (); cmd. commandtype = CT; Res = cmd. executenonquery ();} catch (exception ex) {Throw ex;} finally {If (Conn. state = connectionstate. open) {Conn. close () ;}} return res ;}
The simple method described above is as follows:
Public datatable executequery (string plain text, commandtype CT) {datatable dt = new datatable (); cmd = new sqlcommand (plain text, getconn (); cmd. commandtype = CT; using (SDR = cmd. executereader (commandbehavior. closeconnection) {DT. load (SDR) ;}return DT ;}
4. Tips: add comments. Using region to add comments is easier to hide.
# Add ten popular news articles to region /// <summary> /// retrieve the top 10 news articles (category, news title, and release time) /// </Summary> /// <returns> </returns> Public datatable selectnewnews () {return sqlhelper. test ("procnewsselectnewnews");} # endregion
5. An attribute that keeps the position of the scroll bar unchanged
maintainscrollpositiononpostback = "true"