Declare new sqldatareader c
Here is the declaration of a new SqlDataReader
object in C#:
SqlDataReader c = null;
Note that I've initialized the object to null
, as it's a good practice to do so to avoid potential null reference exceptions.
Alternatively, you can also use the using
statement to declare and dispose the SqlDataReader
object:
using (SqlDataReader c = new SqlDataReader())
{
// use the reader here
}
This way, the SqlDataReader
object will be automatically disposed when you're done using it, which is a good practice to follow.