Micro Focus QTP (UFT) Forums
MySql connection ressource need to be freed ? - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: MySql connection ressource need to be freed ? (/Thread-MySql-connection-ressource-need-to-be-freed)



MySql connection ressource need to be freed ? - gerfred - 07-21-2010

Hi,

I ve read the "Database Checkpoint and QTP" blog from Saket, it was really helpful

I would like to know if used ressources (like oConnection = CreateObject("ADODB.Connection") or recordSet) need to be freed (and when/how if needed) ? or if they are auto freed at the end of the test run.


Second point, is there a way to build a connection string with an encrypted password instead of a clear one ? (just to not having readable DB password in multiple places)

regards,


RE: MySql connection ressource need to be freed ? - Saket - 07-22-2010

whenever you create an object, it is always a good practice to free up the allocation used by the object. it depends on the scope of the object you are using in. e.g. the connection object you mentioned would be limited to your work in the part of your script which is related to do with databases otherwise no, so close/free up the object as soon as you finish the things. see the examples given the post.
you can do this by setting the object as Nothing somthing like
Code:
Set oConnection = Nothing

on the second point:
one of the way could be to store the username and password encrypted in the registry.
for more details. this is from coding point of view, but may be you can get an idea from this.
you can also visit http://www.connectionstrings.com/mysql


RE: MySql connection ressource need to be freed ? - gerfred - 07-23-2010

thanks for the answer.

it seems that msdn link does not work


RE: MySql connection ressource need to be freed ? - Saket - 07-23-2010

very sorry for that, actually i just did a copy paste there
check this out - http://msdn.microsoft.com/en-us/library/Aa302406


RE: MySql connection ressource need to be freed ? - gerfred - 07-23-2010

link works now
thanks you are really very reactive


RE: Sql server connection ressource need to be freed ? - Priyanka Arya - 08-06-2010

Hi,

For DB connectivity i have to give full connection string with DSN, username, password, SID etc. like this: ConnectionString = "DSN=QTPDSN;Description=desc;UID=;PWD=;APP=;WSID=;DATABASE=;"

but in donot want to give this UID, pwd, WSID in each and every script again again. I want do this setting in DSN and then provide only DSN name in connectingString. Is it possible?

Please reply to me ASAP.

With Regards,
Priyanka


RE: Sql server connection ressource need to be freed ? - basanth27 - 08-13-2010

Priyanaka,
Make it a function. Call it wherever you want to..isint that feasible ?

Defining a DSN is like creating a dependency on that machine. Creating a Connection string on the fly helps you to execute on any machine irrespective of any configuration.