日期:2014-05-18  浏览次数:20732 次

c# 求逐行解释,附有详尽代码
/// <summary>  
  /// 查询
  /// </summary>
  /// <param name="p_Sql">sql命令</param>
  /// <param name="p_ParaList">参数集</param>
  /// <param name="p_Type">命令类型</param>
  /// <returns>查询结果</returns>
  public static DataTable GetTable(String p_Sql, SqlParameter[] p_ParaList, CommandType p_Type)
  {
  SqlCommand command = CreateCommand(p_Sql, p_ParaList, p_Type);//创建Command对象
  Debug.Assert(null != command);
  SqlConnection conn = new SqlConnection(strConn);
  command.Connection = conn;
  SqlDataAdapter adapter = new SqlDataAdapter(command);//创建数据适配器对象
  DataTable table = new DataTable();//数据容器
  adapter.Fill(table);
  return table;
  }
求逐行解释,望高手解答!

------解决方案--------------------
C# code
        public static DataTable GetTable(String p_Sql, SqlParameter[] p_ParaList, CommandType p_Type)
        {
            SqlCommand command = CreateCommand(p_Sql, p_ParaList, p_Type);//创建Command对象
            Debug.Assert(null != command);            //只要语句不是空值
            SqlConnection conn = new SqlConnection(strConn);//创建连接
            command.Connection = conn;//设置连接
            SqlDataAdapter adapter = new SqlDataAdapter(command);//这里面是SQL语句
            DataTable table = new DataTable();//创建表
            adapter.Fill(table);//将查询结果赋给表
            return table;//返回
        }