Fire Station Building Institute (Bkjia.com) Network ProgrammingToday, I found a collection of asp.net skills while hanging out on a well-known blog, so I couldn't help but reprint it to everyone. I hope my friends like it. It's all about detail-based skills.
1. Differences between <% =... %> and <% #... %>:
A: <% =... %> is called when the program is executed. <% #... %> is called after the DataBind () method.
2. What types of data does the control receive?
A: controls that receive Bind, including DropDownList, DataList, DataGrid, and ListBox, which are mainly associated with ArrayList and Hashtable ), dataView (data view) and DataReader can be seated in the future without the error that the able is bundled :)
3. The data obtained by DataBind will be converted to another type by default as String?
DataBinder. Eval (Container. DataItem, "Conversion Type", "format ")
The last "format" is optional. Generally, you do not need to worry about it. Container. DataItem is a bundled data item. "Conversion Type" refers to Integer, String, Boolean.
4. Main namespace:
<% @ Import Namespace = "System. Data" %> used to process Data
<% @ Import Namespace = "System. Data. ADO" %> used when using ADO.net;
<% @ Import Namespace = "System. Data. SQL" %> dedicated to SQL Server databases
<% @ Import Namespace = "System. Data. XML" %> you do not need to view
<% @ Import Namespace = "System. IO" %> used for File Processing
<% @ Import Namespace = "System. Web. Util" %>
<% @ Import Namespace = "System. Text" %> used for Text Encoding
5. common attributes and methods of Connections (SQLConection or ADOConnection:
| ConnectionString: gets or sets the database connection statement.
| ConnectionTimeout: gets or sets the maximum time for connecting to the database, which is also the timeout time.
| DataBase gets or sets the name of the DataBase to be opened on the DataBase server
| DataSource: Get or set DSN. No stranger to everyone :)
| Password
| UserID: Get or set the login name
| State: gets the current join State.
| Open () Open the connection
| Close () Close the connection
| Clone (): Clone a join. (Hehe, the sheep can connect or I can)
Example:
SQLConnection myConnection = new SQLConnection ();
MyConnection. DataSource = "mySQLServer ";
MyConnection. Password = "";
MyConnection. UserID = "sa ";
MyConnection. ConnectionTimeout = 30;
MyConnection. Open ();
MyConnection. Database = "northwind ";
MyConnection. IsolationLevel = IsolationLevel. ReadCommitted
6. common methods and attributes of Command
| ActiveConnection
| Name of the SQL statement or stored procedure (StoredProcedure) executed by CommandText
| Maximum CommandTimeout execution time
| CommandType Command operation types (StoredProcedure, Text, TableDirect). The default value is Text.
| Parameters
| Execute () Execute SQL statements or stored procedures
| ExecuteNonQuery () is the same as above. The difference is that the record set is not returned.
| Clone () Clone Command
Example:
String mySelectQuery = "SELECT * FROM Categories order by CategoryID ";
StringmyConnectString = "userid = sa; password =; database = northwind; server = mySQLServer ";
SQLCommand myCommand = new SQLCommand (mySelectQuery );
MyCommand. ActiveConnection = new SQLConnection (myConnectString );
MyCommand. CommandTimeout = 15;
MyCommand. CommandType = CommandType. Text; </FONT>
7. You can open or close a database in either of the following ways:
1. MyConnection. Open (); // Open the connection
MyConnection. Close ();
2. MyCommand. ActiveConnection. Open ();
MyCommand. ActiveConnection. Close ()
- Four pages in total:
- Previous Page
- 1
- 2
- 3
- 4
- Next Page