C#中怎样逐行从数据库中读取数据

2024-11-23 09:06:49
推荐回答(1个)
回答1:

SqlConnection conn = new SqlConnection(connStr);
conn.Open();
SqlCommand cmd = new SqlCommand("select * from table", conn);
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
//blabla
}