日期:2014-05-18 浏览次数:20712 次
List<string> return_list = new List<string>();//当然也可以用数组,不过数组要定义大小 SqlConnection con = DB.WebConnection();//通过类调用连接上数据库 con.Open();//打开连接 SqlCommand com = new SqlCommand(); com.CommandText = "Select * from Users"; com.CommandType = CommandType.Text; com.Connection = con; SqlDataReader reader = com.ExecuteReader(); while (reader.Read()) { return_list.Add(reader["UserName"].ToString());//循环从库里读取加入到链表 }