PDA

Click to See Complete Forum and Search --> : Difference Between rs.Close and Set rs = Nothing


JazzBass
Nov 21st, 2000, 12:21 PM
Hi,
I'm finally getting this database programming thing under control for the most part (enough to get dangerous :D), but I have a queston concerning the above subject line.

When I open a recordset, set a datagrid.datasource to the recordset, and then set the recordset = nothing, everything is cool.

Now if I do the same thing as above, but close the recordset using rs.close before setting it to nothing, then the recordsource is not seen in the datagrid.

I guess what I'm wondering is, what is the real purpose of the .Close property or method. When should you use .Close

I know the Set rs = Nothing is to take it out of memory. But it is still avaiable to my datagrid. I'm really confused.

Clear as mud right?

Sorry for all of these dumb questions. I'm learning more and more every day.

Thanks,
JazzBass

Nov 23rd, 2000, 03:52 AM
When you do a set myRecordset = Nothing you are simply removing that reference to the data, the datagrid still has a reference to it. When you call myRecordset.Close you are telling the object to close itself.
Since both the variable and the datagrid both point to the same object, the close will prevent the data from being shown on the grid.

If you still want to use the data dont call the .close method. Once you have finished with you variable set it to nothing.

Hopt this helps.

John.