string conn String ConfigurationManager Connection Strings("StudentDBConnectionString"].ToString 0: using (SqlConnection conn =new SqlConnection(connString)) string sqlstr="SELECT* FROM StudentInfo SqlCommand command=new SqlCommand( sqlstr, conn); conn.Open SqlDataReader reader =command. ExecuteReaderO Grid Viewl DataSource reader Grid Viewl Databind( reader. Close( (6)创建 Command对象,执行带参数的存储过程 up FindStudentInfo protected void Page Load(object sender, EventArgs e) string connString ConfigurationManager Connection Strings[ "Student DBConnectionString"].ToStringO using(Sql Connection conn=new SqlConnection(connString)) Sqlcommand sqlcommand =new Sqlcommand("up FindStudentInfo",conn); sqlcommand Command Type =Command Type StoredProcedure SqlParameter stName new SqlParameter("@StudentName", SqlDbType. NChar, 10) shAme.Vae="张三丰"; command Parameters. Add(st Name) conn. Open SqlDataReader reader=sqlcommand. ExecuteReadero while(reader. Reado) Response. Write( reader[0] +""+ reader[ 1]+""+ reader[2]+""+reader [3]+"<br/>);{ string connString = ConfigurationManager.ConnectionStrings["StudentDBConnectionString"].ToString(); using (SqlConnection conn = new SqlConnection(connString)) { string sqlstr = "SELECT * FROM StudentInfo"; SqlCommand command= new SqlCommand(sqlstr, conn); conn.Open(); SqlDataReader reader = command.ExecuteReader(); GridView1.DataSource = reader; GridView1.DataBind(); reader.Close(); } } (6)创建 Command 对象,执行带参数的存储过程 up_FindStudentInfo protected void Page_Load(object sender, EventArgs e) { string connString = ConfigurationManager.ConnectionStrings["StudentDBConnectionString"].ToString(); using (SqlConnection conn = new SqlConnection(connString)) { SqlCommand sqlcommand = new SqlCommand("up_FindStudentInfo",conn); sqlcommand.CommandType = CommandType.StoredProcedure; SqlParameter stName = new SqlParameter("@StudentName", SqlDbType.NChar,10); stName.Value = "张三丰"; sqlcommand.Parameters.Add(stName); conn.Open(); SqlDataReader reader=sqlcommand.ExecuteReader(); while (reader.Read()) { Response.Write(reader[0] + " " + reader[1] + " " + reader[2] +" "+reader[3]+ "<br />"); } } }