1, use the using (Declaration object), using to invalidate the local object, when it is used, either its containing class implements the IDispose interface, or his parent class implements the IDispose interface.
2, Fuzzy query:% for 0 to more than any character; _ represents an arbitrary character; [] place a range in the middle; ^ put in [] represents non (not in this range)
3,npoi Implementing Excel Export Import:
Export to Excel::: (1) The tables in the database are read out and stored in their objects with SqlDataReader
(2) Create an object wk for the Iworkbook interface and give it a file stream parameter--filestream FSREAD=FILE.O
Penread (); Workbooks
(3) wk. Numberofsheet represents the number of worksheets; wk. Getsheetat (index) Gets the table, the object that created the Isheet interface sheet isheet sheet = wk. Createsheet ("Tb_user"); Work table
(4) sheet. Lastrownum represents the index value of the last row; Create IRow object
(5) However row. Lastcellnum represents the last column of the column index value +1; Create Icell Object
Note: Fields with null values in the database should be judged when writing to Excel
Method One: if (! =null)
{
Row. Createcell (3). Setcellvalue (HEADMAP);//If it is not empty, the cell is used. (another meaning is that if it is empty, then this cell is skipped and not assigned, which is not used)
}
Method Two: if (HEADMAP)
{
The Cell object. Empty cells
Cellheadmap.setcelltype (Celltype.blank);
}
else
{
Cellheadmap.setcellvalue (Headmap );
}
(6) Last executed FileStream fswrite=file.openwrite ("filename")
Wk. Write (File stream object Fswrite)
Excel Import to table:::
(1) Read Excel
(2) IRow row = sheet. GetRow (i);
(3) String name = row. Getcell (1). stringcellvalue;/////Example Value/////
(4) Determine if the cell is not empty or the cell format is not blank, the normal assignment, otherwise the assignment is null
(5) When there is a value of NULL, it is not possible to insert null into the database, to insert DBNull.Value. New SqlParameter ("@HeadMap", Headmap==null? DBNull.Value: (object) headmap);//////
Note://when inserting a date
When the Excel date goes to the database, use datetime.fromoadate;
Excel controls insert a database with DBNull.Value
Onject (Datetime.fromoadate ((double) lockdate))
120 days of 1200 hours of pass-through for junior students. NET (iii)