Page shaping
Int newsID=Convert。 toint 32(Request[" newsID "]); //Get the value requested by the client and convert it into an integer.

SqlConnection con = new SqlConnection(" server =。 ; uid = sapwd =; Database = demo "); //Create a connection object and link to the local sql server. The database is demo.

con . Open(); //Open the link

SqlCommand cmd = new SqlCommand(" show news ",con); //Create a sqlcommand object to implement database operations and execute stored procedures. This code is used to execute a stored procedure, and its name is shownews.

cmd。 CommandType=CommandType。 Stored procedure; //Specifies to execute the stored procedure.

cmd。 Parameter. Add("@newsID ",newsid); //The stored procedure has one input parameter, whose name is @newsID and its value is the value of newsID.

SqlDataReader dr= cmd。 ExecuteReader(); //execute

If(dr.Read())// Reads data, and read () is TRUE to indicate that there is data.

{

Label 1。 Text=dr["title"]。 ToString(); //assignment

Text box 1. Text=dr["content"]。 ToString();

}

Dr. Close (); //Close the link