使用DataReader

string sqlStr="select * from tb_news";

SqlCommand myCmd=new SqlCommand(sqlStr,myConn);

myCmd.CommandType=CommandType.Text;

SqlDataReader myDr=myCmd.ExecuteReader();

过程:

创建连接

打开连接

创建Command对象

执行Command的ExecuteReader方法

将DataReader绑定到数据控件中.

关闭DataReader.

关闭连接

原文地址:https://www.cnblogs.com/handsomer/p/4150644.html