I used a sample piece of code from a guy called Peter Schumacher (attached).... maybe this will help you as it has helped me....
Good luck [img]images/icons/smile.gif[/img]
' Database assigns a unique key value at record insertion time.
' So, how can you build a dynamic runtime (per iteration) query to verify that the
' record was successfully written to the database when you don't know the unique key?
' To confirm a successful database change (add/update or delete - think about it)
' we have to dynamically build a sql query select using one or multiple column (field)
' values to build a unique query for each iteration.
' For this example the application is adding a user to a database from a web page. We'll use the
' login name which has to be unique and is verified by the application prior to insert. We could
' enhance this script to verify that it we don't get more than one row - which would mean big
' problems for the application.
' Note that we use Option Explicit so we never worry about using existing (duplicating) incorrect
' (typos) variables.
' Also note that all key "words" in the select could be dynamic and/or originate outside of QTP
' (like form an XML file, passed parameter, spreadsheet or database. What possibilities!
Dim strSQL, strNewSQL,strLOGIN_NAME
' Note that 'blank' is a place holder which should not exist - this way, it should fail and stop the
' run if the follwing string substitution doesn't work "correctly"
strSQL = "SELECT CUSTOMER.LOGIN_ID, CUSTOMERS.LOGIN_NAME FROM <DATABASE>.CUSTOMERS" &_
' Get the users login name from the "local" worksheet, default.xls data table (at run time)
' (the column name is 'loginName')
strLOGIN_NAME = DataTable("loginName",dtLocalSheet)
' Swap the place holder "blank" with real login name
strNewSQL = replace(strSQL,"blank",strLOGIN_NAME)
'Change the source select statement to use the new dynamic SQL query
DbTable("DbTable").SetTOProperty "Source", strNewSQL
strNewSQL = DbTable("DbTable").GetTOProperty("Source")
' Confirm that the current user was added to the database, using his login name and send the result
' to the result report
Reporter.ReportEvent micPass, "Add User To Database:", strLOGIN_NAME & " Query Confirmation Result -->"
Services.LogMessage ("User successfully added to the database: " & strLOGIN_NAME), StatusMsg'
' end of dynamic checkPoint