Connect to database
<Deleetask>
<Add key = "sqllink" value = "Server = yfq-001; uid = ADM; Pwd = sdadm; database = dbmt50"> </Add>
<Add key = "sqllink1" value = "Server = ymc; uid = sa; Pwd =; database = northwind"> </Add>
</Appsettings>
Open connection
String connstr = system. configuration. configurationsettings. deleettings ["sqllink"];
Sqlconnection conn = new sqlconnection (connstr );
Conn. open ();
Add DataGrid
Sqldataadapter DR = new sqldataadapter (sqlstr, Conn );
Dataset DS = new dataset ();
Dr. Fill (DS, "usract ");
If (convert. toint32 (Ds. Tables ["contlist"]. Rows. Count. tostring () = 0)
{
This. Maid = true;
}
This. datagrid1.datasource = Ds. Tables ["usract"]. defaultview;
This. datagrid1.databind ();
Ado. Net Applications
String SQL = "select count (*) as icount from sysoper where LOGNAME = '" + this. usrname. Text + "'";
Sqlcommand comm = new sqlcommand (SQL, Conn );
Sqldatareader DR1 = comm. executereader ();
Dr1.read ();
String COUNT = DR1 ["icount"]. tostring ();
Dr1.close ();
Panel Display bar
<Asp: Panel id = "Panel1" style = "Z-INDEX: 101; left: 64px; overflow: Scroll; position: absolute; top: 288px "runat =" server "Height =" 192px "width =" 568px ">
Div scroll bar
<Div id = "selectshow1" style = "OVERFLOW-Y: auto; OVERFLOW-X: auto; width: 83.08%; Height: pixel">
<Asp: DataGrid id = "datagrid1" runat = "server"> </ASP: DataGrid>
</Div>
Enconding Encryption
System.web.httputility.urlencode(this.txt grpid. Text. Trim ())
System. Web. httputility. htmldecode (request. querystring ["grpid"])
Time Format
D. A single-digit date has no leading zero.
A day in DD month. A single-digit date has a leading zero.
The abbreviation of a day in DDD Week, which is defined in abbreviateddaynames.
The full name of the Day of the dddd Week, which is defined in daynames.
M month number. One-digit month does not have a leading zero.
Mm Month number. A single-digit month has a leading zero.
The abbreviated name of the mmm month, which is defined in abbreviatedmonthnames.
The full name of the mmmm month, which is defined in monthnames.
Y does not contain the year of the epoch. If the year that does not contain the epoch is less than 10, the year that does not have the leading zero is displayed.
YY does not contain the year of the epoch. If the year that does not contain the epoch is less than 10, the year with the leading zero is displayed.
Yyyy includes the four-digit year of the epoch.
Gg period or epoch. This mode is ignored if the date to be formatted does not have an associated period or epoch string.
H 12-Hour. One-digit hours do not have a leading zero.
The hour in HH 12-hour format. The number of hours in a single digit has a leading zero.
H In 24-hour format. One-digit hours do not have a leading zero.
The hour in the 24-hour format. The number of hours in a single digit has a leading zero.
M minutes. The number of minutes in a single digit does not start with zero.
MM minutes. The number of minutes in a single digit has a leading zero.
S seconds. The number of seconds in a single digit does not have a leading zero.
SS seconds. The number of seconds in a single digit has a leading zero.
Pop-up window:
Response. Write ("<SCRIPT> window. Alert ('You have registered successfully! ') </SCRIPT> ");
Response. Write ("<SCRIPT> window. Top. Location = 'index. aspx '</SCRIPT> ");
Vs. net2005 B2 activation number:
Ngbq2kckl31k00
Vs. net2003 and vs. net2005 B1:
Use 2003
C: \ winnt \ Microsoft. NET \ framework \ v1.1.4322 \ aspnet_regiis.exe-I
C: \ winnt \ microsoft. Net \ framework \ v1.1.4322 \ aspnet_regiis.exe-R
Use 2005
C: \ winnt \ Microsoft. NET \ framework \ v2.0.40607 \ aspnet_regiis.exe-I
C: \ winnt \ microsoft. Net \ framework \ v2.0.40607 \ aspnet_regiis.exe-R
How do I remove the last x characters of str? Only the preceding characters are required:
String TMP = Str. substring (0, str. Length-x );
How to retain the first I character of STR:
String TMP = Str. substring (0, I );
How to remove the first I character of STR:
String TMP = Str. substring (X );
How to remove the ABC characters in STR, if any:
String TMP = Str. Replace ("ABC ","");
Use break to exit the if statement.
Use return to exit a function
Use return when the returned value is void;
When the returned value has a specific data type, the corresponding data type is returned.
// Jump
This. response. Write ("<SCRIPT> window. Location. href = 'tlist. aspx '</SCRIPT> ");
// Close
This. response. Write ("<script language = JavaScript> window. Close (); </SCRIPT> ");
// In the pop-up window, refresh the current page width = 200 Height = 200 menu. Tool bar not
// This. response. write ("<script language = JavaScript> window. open ('rows. aspx ', 'newwindow', 'width = 200, Height = 200') </SCRIPT> ");
// In the pop-up window, refresh the current page with a menu. Tool bar
// Response. Write ("<script language = JavaScript> window. Open ('rows. aspx ') </SCRIPT> ");
// In the pop-up window, refresh the current page with a menu. Tool bar. Center
// Response. Write ("<SCRIPT> window. Open ('rows. aspx ',' _ blank '); </" + "script> ");
// In the pop-up window, refresh the current page with a menu. Tool bar.
// This. registerstartupscript ("opennewpage", "<script language = JavaScript> window. Open ('rows. aspx? Id = "+ E. tostring () +" ',' _ blank '); </SCRIPT> ");
// Refresh the second page on the first page of a single point
Response. Write ("<script language = JavaScript> window. opener. Location. href = Window. opener. Location. href </SCRIPT> ");
// Refresh the parent to close the current
Response. write ("<script language = 'javascript '> window. opener. location. href = Window. opener. location. href; window. close (); </SCRIPT> ");
Response. write ("<script language = 'javascript '> window. opener. location. href = Window. opener. location. href; window. close (); </SCRIPT> ");
This. response. write ("<script language = JavaScript> window. open ('webform3. aspx ', 'newwindow', 'width = 200, Height = 200, Top = 200, Left = 400') </SCRIPT> ");
This. response. write ("<script language = JavaScript> window. open ('webform3. aspx ',' _ blank ', 'width = 200, Height = 200, Top = 200, Left = 400'); </SCRIPT> ");
IP address usage:
String hostip = system. net. DNS. gethostbyname (system. net. DNS. gethostname (). Addresslist [0]. tostring ();
This. image1.imageurl = "http: //" + hostip + "/mtamap/000001.bmp ";
// Obtain the host name using the host ip127.0.0.1
Iphostentry hostinfo = DNS. gethostbyaddress ("127.0.0.1 ");
String hostname = hostinfo. hostname. tostring ();
// Locate another directory
String url = "http: //" + hostname + "/mtamap/" + session ["str"]. tostring () + ". BMP ";
This. response. Redirect (URL );
// Hide ie in the toolbar of the menu bar. The following variables are the names of the new window, the width and height of the window, the scroll bar, And the pixel distance between the window and the top and left of the screen. // E. item. attributes. add ("onclick", "window. open ('pdetail. aspx? Id = "+ E. item. cells [1]. text + "', 'newwin', 'width = 750, Height = 600, scrollbars = Yes, Top = 50, Left = 50 ');");
String S = "ABC village machinery land 23423 ";
Int bytecount = system. Text. encoding. Default. getbytecount (s );
Bytecount: obtains the number of bytes occupied by the string in the string variable.