Esempio n. 1
0
        public DataTable ReadTable()
        {
            return(HelperBase.ReadTable(cmd));

            /*
             *  DataTable dt=new DataTable();
             * DbDataReader reader = null;
             * try
             * {
             *  reader = cmd.ExecuteReader();
             *  int fieldc=reader.FieldCount;
             *  for (int i = 0; i < fieldc; i++)
             *  {
             *      DataColumn dc = new DataColumn(reader.GetName(i), reader.GetFieldType(i));
             *      dt.Columns.Add(dc);
             *  }
             *  while (reader.Read())
             *  {
             *      DataRow dr = dt.NewRow();
             *      for (int i = 0; i < fieldc; i++)
             *      {
             *          dr[i] = reader[i];
             *      }
             *      dt.Rows.Add(dr);
             *  }
             *  return dt;
             * }
             * finally
             * {
             *  if (reader != null) reader.Close();
             * }*/
        }
        public static DataTable ReadTable(SqlConnection connection, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
        {
            SqlCommand cmd = new SqlCommand();

            PrepareCommand(cmd, connection, null, cmdType, cmdText, commandParameters);
            DataTable dt = HelperBase.ReadTable(cmd);

            cmd.Parameters.Clear();
            return(dt);
        }