April 4, 2011

Create a function which returns a random number

How to set a "randomValue" to a variable and How to run an UPDATE within a Data Base using this variable
'set a random number - this function will be called to do updates
Function RandomNr
upperbound = 1000-1
lowerbound = i
For i=1 to upperbound
RndNr = Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
RandomNr = RndNr
End Function

DB Update using the "RandomNr" function above:
updateCol1data = UCASE("update tableName set ColumnHere = '" & RandomNr & "' WHERE columnName='value'")

'querying an 'UPDATE' for a fields within DB
Public Function DBUpdate(updateCol1data)
 set conn = createobject("adodb.connection")
 conn.open "DSN=DSN_SERVERhere; UserID=userID; Password=password;"
 conn.Execute updateCol1data
End Function

Now to call this function use next:
DBUpdate updateCol1data


  1. Hello Peterson, as I posted few weeks ago, I am not doing QTP for a long while already. Because of this I am not up to date with the latest news & techniques on QTP (now FTP)... In my last post I was asking people viewing the blog, if there is anyone available and would like to keep updating it, to let me know...

  2. Thanks for posting QTP samples. I need some more QTP samples to understand technically. Software Testing Course in Chennai is good to study or we want go for seprate QTP Training.

    1. Hi venki, I wish I add more examples, but I am not in the field now, so unfortunately I cannot do that. Please check http://www.qtpcenter.com/2014/05/need-volunteers-for-posting-qtp-ftp.html page for more details.

  3. That was a very informative post. Thank you so much. Keep posting more.
    QTP Training Institutes in Chennai | QTP Training Institutes in Chennai

  4. Technology place a vital part in humans ecosystem. So in order to survive one must be up to date. Thanks for sharing this information in here. Keep blogging article like this. I have bookmarked this page for future reference.

    Hadoop Training Chennai | Best hadoop training institute in chennai | JAVA training in Chennai

  5. Hi, I am really happy to found such a helpful and fascinating post that is written in well manner. Thanks for sharing such an informative post.
    QTP Training in Chennai

  6. Thanks for sharing your ideas on mobile application.Really useful to me.Continue sharing more like this.
    Mobile Application Training in Chennai | Mobile Apps Testing Training | Mobile Application Testing Training