PEB 1,418
Expert 1GB
I don't know is there any effect when i'm finishing to use a recordset from VB
and after
rs.close
i set rs to:
set rs=nothing
Pls explain me what is the effect of set rs=nothing
Is there any economy of memory, or something simillar??
I've tought that rs.close and then mydb.close are enough to close and free the memry for those objects...
Thank you
PEB
6 4382 NeoPa 32,556
Expert Mod 16PB
Every object variable is a link to an object (or it's set to Nothing).
This is particularly important to understand for temporary objects.
When an object var is set to nothing then it will be 'closed' automatically. This is handled by the compiler as differen objects have different meanings for 'Close'.
It is therefore not necessary to close the object explicitly.
However, whan a variable loses scope (a local variable in a procedure, for instance, when the procedure is 'Exit'ed), it is automatically set to nothing intrinsically.
The important thing about Temp objects is that they will remain in existense, only while at least one object variable refers to them. Once the last is set to Nothing, the object disappears.
It's also important to bear in mind, that there are code structures (With TempObj...End With is one that comes to mind) which will keep a link to the object similar to an object variable. In this case the temporary object would also remain until this usage or reference has been released.
PEB 1,418
Expert 1GB
Ok. Thanks NeoPa for this good explication.. In my case i've uset the recordset variable only in functions...
So when the functions finish their work the recordset object varibles that have been used desappear... So in my case there isn't any problem...
In those functions everytime i've used mys.close and mydb.close coz I've setted the database using set mydb=currentDb()
Maybe it's the time to say that if mydb is setted using Workspace and Database a command like mydb.close can close the current database directly...
So i don't need to correct my function writing Set rs= nothing
Thank you NeoPa
:)
NeoPa 32,556
Expert Mod 16PB
I never use a separate variable for CurrentDB - CurrentDB is there, available all the time.
Also CurrentDB won't close with a call like
I never use a separate variable for CurrentDB - CurrentDB is there, available all the time.
Also CurrentDB won't close with a call like
Your suggestion is good from a pure coding standpoint, but when you consider performance, it may not work.
I tested this back in Access 97, and CurrentDB() calls are slow. I can't remember how slow, but I want to say at least 100 or 200ms. Maybe they've been sped up in latter Access versons? In any case, people should look out for this when using CurrentDB. Other than that, CurrentDB is great.
Jason
NeoPa 32,556
Expert Mod 16PB
Interesting point Jason.
Would I take that to mean that assigning a db Variable to point to CurrentDB and using that variable in the following code would be a more efficient approach?
Where possible, I always use the With ... construct, which probably saves me from similar type issues in my code.
NeoPa 32,556
Expert Mod 16PB
FYI This thread was done in my first fortnight as a member here.
Seems like a lifetime ago :D
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Alexander Zatvornitskiy |
last post by:
Hello All!
I'am novice in python, and I find one very bad thing (from my point of view) in
language. There is no keyword or syntax to declare variable, like 'var' in
Pascal, or special syntax in...
|
by: doltharz |
last post by:
Please Help me
i'm doing something i though was to be REALLY EASY but it drives me
crazy
The complete code is at the end of the email
(i mean newsgroup article),
i always use Option...
|
by: Defused |
last post by:
> i have a file named CDSEncoder.cpp, and i wanted to create a member variable
> of this in KNNDlg.cpp...so i wrote the following under my KNNDlg.h file
>
> protected:
> CDSEncoder m_encoder;
>...
|
by: James A. Donald |
last post by:
I am contemplating getting into Python, which is used by engineers I
admire - google and Bram Cohen, but was horrified to read
"no variable or argument declarations are necessary."
Surely that...
|
by: Steve Jorgensen |
last post by:
Many of the regulars here have explained that declaring variables using As New
.... is a bad idea, and some have given some good explanations, but I wanted
add one more demonstration to the mix. ...
|
by: Mike |
last post by:
I have a function that is called when the user clicks the submit button,
during this function i also set a varaible to "Y" due to that this function
does a post back to the page then redirects....
|
by: Shapper |
last post by:
Hello,
I am declaring a variable in my aspx.vb code as follows:
Public Class catalogue
Public productid As String
Private Sub Page_Load
...
I have an image button where I call the...
|
by: Jody Gelowitz |
last post by:
I have run into an issue with variable scope within an XSLT document that is translated in VS.NET 2.0. Under VS.NET 1.1 (XslTransform), this code works fine. However, when using VS.NET 2.0...
|
by: estantep |
last post by:
Hello,
I am trying to find out an alternate way to brute-force a variable
length vector with different variable length contents.
int chromossome
int max_value_for_each_chromossome
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |