打印本文 打印本文 关闭窗口 关闭窗口
第四课 使用SqlDataReader读取数据(翻译)
作者:武汉SEO闵涛  文章来源:敏韬网  点击数15050  更新时间:2007/11/14 13:12:43  文章录入:mintao  责任编辑:mintao
Getting an instance of a SqlDataReader is a little different than the way you instantiate other ADO.NET objects.  You must call ExecuteReader on a command object, like this:

得到SqlDataReader对象于实例化其它ADO.NET对象稍微有些不同。你必须对一个command对象调用ExecuteReaer方法,比如这样:

    SqlDataReader rdr = cmd.ExecuteReader();

The ExecuteReader method of the SqlCommand object, cmd , returns a SqlDataReader instance.  Creating a SqlDataReader with the new operator doesn''''t do anything for you.  As you learned in previous lessons, the SqlCommand object references the connection and the SQL statement necessary for the SqlDataReader to obtain data.

SqlCommand对象cmdExecuteReader方法返回一个SqlDataReader实例。使用new关键字创建一个SqlDataReader并不做任何事情。前面的课程已经学到,SqlCommand对象引用connectionSQL语句对于SqlDataReader读取数据是必需的。

Reading Data

读取数据

Previous lessons contained code that used a SqlDataReader, but the discussion was delayed so we could focus on the specific subject of that particular lesson.  This lesson builds from what you''''ve seen and explains how to use the SqlDataReader.

上一页  [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]  ...  下一页 >> 

打印本文 打印本文 关闭窗口 关闭窗口