在数据库中查询大量的数据时返回单个数据行的方法
public sqlDataReader ExecuteReader(string sql,SqlParameter[] params)
{
SqlConnection conn=new SqlConnection(connStr);
conn.open();
using(SqlCommand cmd=new SqlCommand(sql,conn))
{
cmd.Parameters.AddRange(params);
return cmd.ExecuteReader(CommandBehavior.CloseConnection);
}
}
本文详细介绍了在数据库中使用SQL查询语句并结合参数,通过`ExecuteReader`方法来获取大量数据中的单个数据行的过程。重点阐述了如何设置连接、执行SQL命令以及返回查询结果。
202

被折叠的 条评论
为什么被折叠?



