解决方法
using (sqlConnection cnn = new sqlConnection("server=(local);database=pubs;Integrated Security=SSPI")) { sqlDataAdapter da = new sqlDataAdapter("select name from authors",cnn); DataSet ds = new DataSet(); da.Fill(ds,"authors"); List<string> authorNames = new List<string>(); foreach(DataRow row in ds.Tables["authors"].Rows) { authorNames.Add(row["name"].ToString()); } }
将作者姓名填入List的非常基本的示例.