C# Arraylist的Arraylist…在c中#

C# Arraylist的Arraylist…在c中#,c#,arraylist,C#,Arraylist,我需要从SQL查询中获取数据,我有一个方法返回arraylist of arraylist,但我无法显示SQL查询返回的数据 我编写了返回sql查询的方法: public ArrayList ejecutarSelect(string sentenciaSQL){ if (this.conn.State != System.Data.ConnectionState.Open)this.Conectar(); ArrayList rows = new ArrayList();

我需要从SQL查询中获取数据,我有一个方法返回arraylist of arraylist,但我无法显示SQL查询返回的数据

我编写了返回sql查询的方法:

public ArrayList ejecutarSelect(string sentenciaSQL){

    if (this.conn.State != System.Data.ConnectionState.Open)this.Conectar();

    ArrayList rows = new ArrayList();
    MySqlCommand cmd = new MySqlCommand(sentenciaSQL, this.conn);
    try
    {
        MySqlDataReader dataReader = cmd.ExecuteReader();
        if (dataReader.HasRows)
        {
            while (dataReader.Read())
            {
                ArrayList row = new ArrayList();
                for (int i = 0; i < dataReader.FieldCount; i++) row.Add(dataReader.GetString(i));
                rows.Add(row);
            }
        }
        dataReader.Close();
    }
    catch (Exception e)
    {
        CLog.log("ERROR (CDBMgr): " + e.Message);
        return null;
    }

    return rows;
}
public ArrayList ejecutarSelect(字符串判决asql){
如果(this.conn.State!=System.Data.ConnectionState.Open)this.Conectar();
ArrayList行=新的ArrayList();
MySqlCommand cmd=newmysqlcommand(sentensionasql,this.conn);
尝试
{
MySqlDataReader=cmd.ExecuteReader();
if(dataReader.HasRows)
{
while(dataReader.Read())
{
ArrayList行=新的ArrayList();
对于(inti=0;i

上面说

不进行任何转换;因此,检索到的数据必须已经是字符串


那么..

您有什么理由首先要使用非泛型集合吗?“我无法显示查询sql返回的数据”->,那么您会得到什么呢?我需要检索该表中的所有项,而不是如何将一个arraylist访问到另一个arraylist。对不起,我说的是英语…你能使用实体框架让事情变得更简单吗?OP会变为null或是一个空的
ArrayList
row.Add(dataReader[i].ToString());