Fork me on GitHub

使用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.

关闭连接

 

posted @ 2014-12-08 11:20  乔闻  阅读(111)  评论(0编辑  收藏  举报