表A有字段id  name
         1    aa
         2    bb
         3    cc
        ...   ...
        ...   ...表中数据可能是更多条
while循环后,希望得到 
1,aa;2,bb;3,cc ...
该如何实现?多谢.

解决方案 »

  1.   

    while循环?
     你查询出来返回的是个什么数据集合?
       while (rdr.Read())
                    {                    co = this.SetReader(rdr);
                    }
     private BrandInfo SetReader(SqlDataReader rdr)
            {
                BrandInfo co = null;
                co = new BrandInfo();
                co.Id = rdr.GetInt32(0);            if (!rdr.IsDBNull(1))
                    co.Name = rdr.GetString(1);
                else
                    co.Name = "";            if (!rdr.IsDBNull(2))
                    co.Re = rdr.GetString(2);
                else
                    co.Re = "";
                return co;        }
    是要这个??
     
      

  2.   

    表A有字段id  name 
            1    aa 
            2    bb 
            3    cc 
            ...  ... 
            ...  ... 我连的MySQL,
     MyCmd = new MySQLCommand("select * from A", MySQLConn);
                MySQLDataReader MyRead = (MySQLDriverCS.MySQLDataReader)MyCmd.ExecuteReader();
                while (MyRead.Read())
                {
                    string a=MyRead["id"].tostring();
                    string b=MyRead["name"].tostring();
                }
    我希望最后得到
    1,aa;2,bb;3,cc ....
      

  3.   

    表A有字段id  name 
            1    aa 
            2    bb 
            3    cc 
            ...  ... 
            ...  ... 我连的MySQL, 
    MyCmd = new MySQLCommand("select * from A", MySQLConn); 
                MySQLDataReader MyRead = (MySQLDriverCS.MySQLDataReader)MyCmd.ExecuteReader(); 
     string a ="";
                while (MyRead.Read()) 
                { 
                    a  +=MyRead["id"].tostring()+","MyRead["name"].tostring()+";"+; 
                }
     
    试试!看成不!
    我希望最后得到 
    1,aa;2,bb;3,cc ....
      

  4.   

    没玩过MYSQL 不过SQL语句应该是一样的吧
    select id+','+name as idandname from a循环里直接
    a  +=MyRead["idandname "].tostring()+";"; SQL中还可以用SQL函数直接返回你要的串