Micro Focus QTP (UFT) Forums
Why Constant Variables while connecting to DB - 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: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Why Constant Variables while connecting to DB (/Thread-Why-Constant-Variables-while-connecting-to-DB)



Why Constant Variables while connecting to DB - mona - 07-26-2009

Hi,

I tried to get the count from some table but didn't suceed.

One of my colleague asked me to add the following lines in DB Connection query:
Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adUseClient = 3

Can anybody please explain what are these variables and why do we need to add these constant variables.

Thanks,
Mona


RE: Why Constant Variables while connecting to DB - Saket - 07-27-2009

These are the cursors which controls the navigation of records in a recordset and how the records will be updated.
I have tried to explain this, hope this will help you

adOpenForwardOnly - this is the default cursor if no other is specified. This cursor allows only forward movement through a recordset

adOpenKeyset - this cursor supports forwards as well as backwards navigation. It also allows you to update a recordset and all changes will be reflected in other users recordsets. The cursor also supports bookmarking

adOpenDynamic - this cursor supports forward and backward navigation but bookmarks may not be supported (ie Access). Any changes made to data are immediately visible with no need to resynchronise the cursor with the database

adOpenStatic - this cursor uses a static copy of data from the database and therefore no changes to the data are visible and supports forward and backward navigation
adUseClient - using this cursor recordset will be in read only mode i.e. the recordset cannot be used to update records in the database. A recordset with the CursorLocation asUseClient is typically used when an active Recordset is Disconnected for viewing data.

The locktype parameter specifies which type of locking should be used on the cursor when editing data in a recordset

adLockReadOnly - default type used when no locktype is specified
adLockPessimistic - forces the database to lock the entire record when editing first starts
adLockOptimistic - locks records only after you call the UPDATE method of the recordset object
adLockBatchOptimistic - allows batch updating instead of updating each record individually


RE: Why Constant Variables while connecting to DB - mona - 07-27-2009

Hi Saket,
Thank you very much for answering my query.
It would be realy helpful if you can give me any link or tutorial which can help me understand this better, like which cursor to be used and when.
Thanks,
Mona


RE: Why Constant Variables while connecting to DB - Saket - 07-27-2009

Hi Mona,

PLease follow the link
http://dev.mysql.com/tech-resources/articles/vb-cursors-and-locks.html


Thanks,
~Saket


RE: Why Constant Variables while connecting to DB - mona - 07-27-2009

Hi Saket,
I appreciate the time you took to answer my questions...
Have a Good Day...
Thanks,
Mona