Streamread and Sqlparamter,sql connection queries and paging
-> XML Operations
InnerText will label <> escape
INNERXML does not escape the label
Commissioned
Multicast delegates.
--Write TXT
Streamwrite writes to the text reader. FieldCount get the number of fields
The WriteLine () method of the Streamwrite object can write the read content to txt
Streamread Read text
string temp;
while (temp = reader. ReadLine ())!=null) indicates read data
Quite right to remove the ID from the increase.
Temp=regex.replace (temp,@ "^d+,", "");
string [] Strs=temp.split (new char[] {', ', stringsplitoptions.removeemptyenetits}
This time the length is 10 before writing to the database
STRs the ID of the lower table 0 is the unwanted data self increase
if (strs.leng==10)
{
String Sqltemp=string.format (Sql,strs);
}
--Prevent SQL injection
2. Bind the user's input to the parameter alias, using the Sqlparamter class
SqlParameter p1 = new SqlParameter ("@username", UID);
SqlParameter P2 = new SqlParameter ("@password", PWD);
Add to cmd inside
Cmd. Parameters.Add (p1);
Cmd. Parameters.Add (p2);
--The simplest SqlParameter object to add
Cmd. Parameters.addwithvalue ("@username", username);
--Cross-check
Mainly used in auxiliary tables
Select T2.num*10,t1.num+1 from Tblnumber as T1 cross join Tblnumber as T2;
Generates 1-100 of the number order by 1; Sort starting from 1
--Inner link
--External links
--Use one query as the data source for another query (derived table)
--The query will be queried (not allowed by the order by unless it is used with top)
As the data source, put it behind from and use parentheses to take the alias as T1 (result set)
--The Alias boot field is used in the select.
--Pagination * * *
C#
-math.celling () returns the function of the current page
(int) Math.ceiling (Rows * 1.0/10);
lable text box. Text=string.format ("{0}/{1}", 1,countpage); --countpage Total Pages
lable text box. Text=regex.replace (lable text box text,@ "^/d+/", page+ "/");
is to find the number/replace into page/;
--pagination
between 1 and 10; Statement
SELECT * FROM student where
Stuid between (@page-1) * @count +1 and (@page *count);
2-1*5+1 and 2*5
--Introduce a ranked function Row_number () function in SQL Server 2005
Row_number () over (order by Stuname); Must follow over () collation after line