连接方式访问数据库的步骤:
//1.创建连接对象
//2.创建命令对象
//3打开数据库连接
//4发送命令
//5处理数据
//6关闭数据库连接
非连接方式访问数据库的步骤:
//1创建连接对象
SqlConnection con = new SqlConnection(Config.GetConnectionString());
//2创建数据适配器对象
//SqlDataAdapter da = new SqlDataAdapter("SELECT Student.*, Class.ClassName AS Expr1 FROM Class INNER JOIN Student ON Class.ID = Student.ClassId ORDER BY Class.ID", con);
SqlDataAdapter da = new SqlDataAdapter("Student_GetAllInfo", con);
此代码相当于以下代码
//SqlCommand cmd = new SqlCommand();
//cmd.CommandText = "Student_GetAllInfo";
//cmd.CommandType = CommandType.StoredProcedure;
//cmd.Connection = con;
//da.SelectCommand &