| || |
dynamic db checkpoint
I am a new QTP user and I am trying to make a checkpoint with a dynamic SQL, for instance, here is what I'm trying to do, this is a contact entry.
1. Enter contact info using random number for patient number
2. Run SQL Query to return row from SQL server using the random number from #1 as the Where clause
3. Verify the record components
I can do the above, but I am not sure how to change the SQL query at runtime.
Re: dynamic db checkpoint
You can generate random number in QTP. Here is a ADODB code that will help you
1. You need either DSN to connect to your DB
2. Or, you should know the connection string
</font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">PatientNumber = "your random patient number"
Set Con = CreateObject("ADODB.Connection"
Set Rs = CreateObject("ADODB.Recordset"
Con.Open "put here your DSN name or connection string"
Rs.Open "Select * from patients where patient_number=" & PatientNumber",Con</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">Now you can validate your record using RS recordset. You can refer fields from the Query
For more information refer MSDN for ADODB Connection and Recordset objects.