1.

How Do You Create An Instance Of Sqldatareader Class?

Answer»

To CREATE an instance of SqlDataReader CLASS, you must call the ExecuteReader method of the SqlCommand object, instead of DIRECTLY using a constructor.

//Error! Cannot use SqlDataReader() constructor to create an instance of SqlDataReader class. SqlDataReader ReaderObject = NEW SqlDataReader(); //Call the ExecuteReader method of the SqlCommand object SqlCommand CommandObject = new SqlCommand(); SqlDataReader ReaderObject = CommandObject.ExecuteReader();

Creating an instance of SqlDataReader class using SqlData Reader() constructor generates a COMPILE time error - The type 'System.Data.SqlClient.SqlDataReader' has no constructors defined.

To create an instance of SqlDataReader class, you must call the ExecuteReader method of the SqlCommand object, instead of directly using a constructor.

Creating an instance of SqlDataReader class using SqlData Reader() constructor generates a compile time error - The type 'System.Data.SqlClient.SqlDataReader' has no constructors defined.



Discussion

No Comment Found