Originally Posted by ericgmejia
dim bReturn as boolean;
tama ka.
bReturn is a variable sa loob ng function testConnection
it will pass the result of the function OUTSIDE of the function
becuase of
testConnection = bReturn
so pag tinawag mo ang function frm another function like
dim result as boolean
result = TestConnection
you will know ang resulta ng function via vaiable 'result'
kung true or false ang testing ng connection.
what do u mean by "Set conn = Nothing",
mapapansin mo na yung function ay walang ginamit na variable na form level, public or module level variable EXCEPT 'gstrConnectionString'
i want to keep my functions independent as much as possible, so lahat ng kelangan ng function para tumakbo ay nasa loob na neto, except for one or 2 na kelangan talaga.
connection object 'conn' was declared inside the function, tama?
so i want to clear my objects from memory before i exit from the function
setting the object to 'nothing' is a good way to do it.
remember VB6 has no Garbage Collector like VB.NET
so i keep my object as tight as possible,
meaning smallest scope as much as possible, smallest scope is inside a function, not within a form or public.
i did not declare my 'conn' in module, form or public to save memory,
may overhead yan sa speed during the first few connections since bago ang connection mo everytime,
pero if you use SQLServer or server based RDBMS, meron Connection Pooling, meaning SQLServer will reuse the last connection for you, bibilis na sya nun.
by saving memory maiiwasan mo ang HANG pag matagal na tumatakbo ang program mo, hindi magiging sluggish ang gui.
setting an object to NOTHING destroys the object,
opposite of declaring the object.
ginawa ang VB6 para di na problemahin ng programmer ang mga memory issues unlike sa C++, pero responsible ka parin dapat na maging maayos ang program mo na tumtakbo.
sir pa-refer nalang po dito. salamat.
so meaning to say, declaring conn in a form or module will cause a slow in speed when executing the program.
the best way to make ur project independent as much as possible at para mapabilis is to declare the conn to function not to a module, form or public.
ang kahalagahan nito para sa stand-alone na program ya maiiwasan ang hung kahit matagal syang nagra-run. ok sir thanks...
so in everytime i will add a new data to database, tatawagin ko ung ginawa kong object sa function para makapagsave?
for me, studying your code will take a long time to understand the flow and logic because i need to know every function of the syntax on it. very challenging sir. is the reward for completing the add command is still open? thanks anyway.