What Will happen? 
Author Message
 What Will happen?

What will happen if i not use these ending code?

rst.close
set rst = Nothing
set db = Nothing



Sat, 14 Oct 2000 03:00:00 GMT  
 What Will happen?

Hi Kenny,

rst.close closes the recordset, if you don't and you rerun the code then yu
risk having an error on the OpenRecordset statement.

Set rst=Nothing and Set db=Nothing cleans up the variables from memory and
frees up memory space

Johan Savels
Trainer Data Bases & Visual Basic
Royal Technical School of the Belgian Airforce

Quote:

>What will happen if i not use these ending code?

>rst.close
>set rst = Nothing
>set db = Nothing



Sat, 14 Oct 2000 03:00:00 GMT  
 What Will happen?


Quote:
> What will happen if i not use these ending code?

> rst.close
> set rst = Nothing
> set db = Nothing

What will happen? Nothing special. Access promises that it will take care
of this for you (that is, closing the recordset and releasing the
references to the objects in memory, thereby removing them from memory if
possible) when the variables go out of scope.

OTOH, it's just good practice to "put your toys away when you're done
playing with them." There are some situations (I've not been able to
reproduce this, but it DOES happen) where applications are unable to
close (that is, Access won't quit) because the developer has left open
some DAO reference. In other words, this is just a good idea, as a
precaution, and good programming style. -- Ken



Sat, 14 Oct 2000 03:00:00 GMT  
 What Will happen?

I always use the rst.close and db.close methods.  On the other hand, since
Access (and VB) will clear the memory for you when variables go out of scope
(you are using parameters and local variables, aren't you), setting
variables to nothing simply slows down your code at runtime since Access
isn't a fully compiled language.

See Ken's comments about cleaning up after yourself.  This applies to all
system resources and the .close method is what does it for almost all
objects.

Mike Ober.

Quote:


>> What will happen if i not use these ending code?

>> rst.close
>> set rst = Nothing
>> set db = Nothing

>What will happen? Nothing special. Access promises that it will take care
>of this for you (that is, closing the recordset and releasing the
>references to the objects in memory, thereby removing them from memory if
>possible) when the variables go out of scope.

>OTOH, it's just good practice to "put your toys away when you're done
>playing with them." There are some situations (I've not been able to
>reproduce this, but it DOES happen) where applications are unable to
>close (that is, Access won't quit) because the developer has left open
>some DAO reference. In other words, this is just a good idea, as a
>precaution, and good programming style. -- Ken



Sat, 14 Oct 2000 03:00:00 GMT  
 What Will happen?

This is NOT true.  Setting variables to nothing EXPLICTLY frees up the
object pointer that still exists even if the db is closed.  For example, try
this from the i-pane:

Set db = OpenDatabase("foo.mdb")
db.Close
? db is nothing

It will say FALSE because db is not nothing.  There are known bugs with the
references memory not being freed when you do not explicitly free these
vars, due to the coplex interactions of DAO, JET, VBA, and transactions. Add
to that the fact that Access will stay open until all of these objects are
gone, and you can sometimes have an Access that will not close.

Michael



Quote:
>I always use the rst.close and db.close methods.  On the other hand, since
>Access (and VB) will clear the memory for you when variables go out of
scope
>(you are using parameters and local variables, aren't you), setting
>variables to nothing simply slows down your code at runtime since Access
>isn't a fully compiled language.

>See Ken's comments about cleaning up after yourself.  This applies to all
>system resources and the .close method is what does it for almost all
>objects.

>Mike Ober.



>>> What will happen if i not use these ending code?

>>> rst.close
>>> set rst = Nothing
>>> set db = Nothing

>>What will happen? Nothing special. Access promises that it will take care
>>of this for you (that is, closing the recordset and releasing the
>>references to the objects in memory, thereby removing them from memory if
>>possible) when the variables go out of scope.

>>OTOH, it's just good practice to "put your toys away when you're done
>>playing with them." There are some situations (I've not been able to
>>reproduce this, but it DOES happen) where applications are unable to
>>close (that is, Access won't quit) because the developer has left open
>>some DAO reference. In other words, this is just a good idea, as a
>>precaution, and good programming style. -- Ken



Sat, 14 Oct 2000 03:00:00 GMT  
 What Will happen?

Is this the same Ken Getz  who wrote the forward in Database Design for Mere
Mortals?  If so I agree it is a great book, at least for this mere mortal.
I've been taking Access classes at Catapult and this book brought it into
focus for me.  Just like turning on the light.

If any other newbies want to really learn hoe to design a database take a
look at this book.  I got mine at Tower, but I saw it was available at
Amazon.

Don

Quote:


>> What will happen if i not use these ending code?

>> rst.close
>> set rst = Nothing
>> set db = Nothing

>What will happen? Nothing special. Access promises that it will take care
>of this for you (that is, closing the recordset and releasing the
>references to the objects in memory, thereby removing them from memory if
>possible) when the variables go out of scope.

>OTOH, it's just good practice to "put your toys away when you're done
>playing with them." There are some situations (I've not been able to
>reproduce this, but it DOES happen) where applications are unable to
>close (that is, Access won't quit) because the developer has left open
>some DAO reference. In other words, this is just a good idea, as a
>precaution, and good programming style. -- Ken



Sat, 14 Oct 2000 03:00:00 GMT  
 What Will happen?

Quote:

> Is this the same Ken Getz  who wrote the forward in Database Design for Mere
> Mortals?

And a couple of other little snippets ...

Regards,

S.Y.



Sun, 15 Oct 2000 03:00:00 GMT  
 What Will happen?


Quote:
> Is this the same Ken Getz  who wrote the forward in Database Design for Mere
> Mortals?  If so I agree it is a great book, at least for this mere mortal.

Yes, that would have been me. I recommend the book quite often. -- Ken


Sun, 15 Oct 2000 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Help wanted - willing to pay fair hourly rate

2. A Willing Volunteer to translate WB to VBA

3. A willing person to convert WB to VBA

4. Willing to work for free....

5. Anyone willing to help HS student?

6. Anyone willing to help HS student?

7. Forms of a willing shape

8. Willing to pay for a searchable Internet Database

9. Anyone willing to be a mentor?

10. anyono willing to give help

11. In need of a programmer. Willing to pay

12. Willing to pay for a searchable Internet Database

 

 
Powered by phpBB® Forum Software