executereader
using (sqlConnection conn = new SqlConnection(
"Data Source = .;Initial Catalog = DB1;User ID = sa;Password = zxcasd"))
{
conn.Open();
using (Sqlcommand cmd = conn.CreateCommand())
{
cmd.CommandText = "select * from T_student";
using (Sqldatareader reader = cmd.executeReader())
{
List<string> lName = new List<string>();
while (reader.Read())
{
string name = reader.GetString(1);
lName.Add(name);
}
listName.ItemsSource = lName;
}
}
}
文章最后发布于: 2016-06-22 10:32:25
相关阅读
ExecuteNonQuery(),ExecuteScalar(),ExecuteReader的
转载于http://www.cnblogs.com/asdyzh/p/9741641.html ExecuteNonQuery(),ExecuteScalar(),ExecuteReader的用法-转 using Syste
在做数据库的查询过程中,使用方法ExecuteReader,其返回结果为MySqlDataReader,由于参考的信息有误,走了好长时间的弯路,记录下来; stri