SqlDataReader 的定义:
public sealed class SqlDataReader : MarshalByRefObject,
IEnumerable, IDataReader, IDisposable, IDataRecord若要创建 SqlDataReader,必须调用 SqlCommand 对象的 ExecuteReader 方法,而不直接使用构造函数。
public sealed class SqlDataReader : MarshalByRefObject,
IEnumerable, IDataReader, IDisposable, IDataRecord若要创建 SqlDataReader,必须调用 SqlCommand 对象的 ExecuteReader 方法,而不直接使用构造函数。
而若要创建 SqlDataReader,必须调用 SqlCommand 对象的 ExecuteReader 方法,而不直接使用构造函数,所以不用被实例化。
回复人: qiuji(忆秋季) ( ) 信誉:99 2003-10-08 21:57:00 得分:0
例如:SqlConnection 构造函数,就是初始化 SqlConnection 类的新实例。
而若要创建 SqlDataReader,必须调用 SqlCommand 对象的 ExecuteReader 方法,而不直接使用构造函数,所以不用被实例化。
----------------------------------------
清晰,支持
“若要创建 SqlDataReader,必须调用 SqlCommand 对象的 ExecuteReader 方法,而不直接使用构造函数”
再看看这句话,“必须调用”,如果有构造函数,就可以使用构造函数了,也就可以创建SqlDataReader了,那就不需要说“必须调用”了。
被sealed的东西是不能new的
c++清清楚楚!
private myclass() {
}
}你试一下 new myclass 行不行就知道了
此话不对吧
for example:using System;
sealed class MyClass
{
public int x;
public int y;
}class MainClass
{
public static void Main()
{
MyClass mC = new MyClass();
mC.x = 110;
mC.y = 150;
Console.WriteLine("x = {0}, y = {1}", mC.x, mC.y);
myReader.myCommand.ExecuteReader();
SqlDataReader myReader;
myReader=myCommand.ExecuteReader();