SqlDataReader dreader = new SqlDataReader();
...
...
...
how to clear the dreader instance in memory? Is it dreader.Close() or dreader = null.
thanks in advance.
Printable View
SqlDataReader dreader = new SqlDataReader();
...
...
...
how to clear the dreader instance in memory? Is it dreader.Close() or dreader = null.
thanks in advance.
You can't create an data reader using the "new" keyword as it has no public constructor, but assuming you have created one by calling ExecuteReader on a command, all you have to do is call Close on it. You can set the variable to null as well if you like, but that will have no real effect unless your variable remains in scope for some time after you've finished using the data reader. Setting the variable to null removes the reference to the object and thus makes it eligible for garbage collection, but that will happen as soon as the variable loses scope anyway, so if it is a local variable then setting it to null serves no useful purpose.
yap i can create that way. and thanks for ur advice.