You don't need to know much about Testpartner as such to be able to use SQL because you'll mainly be using VBA asssets.
You'll find lots of posts on this subject if you do a search on "SQL", for example SQL in TP shows how to make a SQL query using ADO Recordsets.
There are many approaches to handling errors.
If you are already using error handling for scripts then you should choose a method that is consistent with that. If not, you will need to think about what it is you are testing and what you want to do in the event of a database error. Would it make sense for the script simply to end and report the error?
Thank you Bobbo, I'm able to connect to database and fetch the data from it.
Actually i want to know how to handle the errors that occur during the database access i.e.
1. Database name might be given wrong.
2. Table name or Field name might be wrong.
In this case how can i handle in my script.
It does depend on what you want to do. Are you testing something and if so what? If you are, you may want the script to stop running at the the first error it encounters and provide an error report. If you automating a task and want the script to continue if possible if an error occurs then you will have to give more details.
You can use the following to stop the script if a database error (and most other types of error) occurs and provide a brief report. You will need to set TP's VB error trapping to "Break on Unhandled Errors" under Tools>Visual Basic Options>General.
</font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">
' Enable the error handler
On Error GoTo ErrorHandler
' Db code taken from "SQL in TP" post
Dim adoConnection As ADODB.Connection
Set adoConnection = New ADODB.Connection
' End of db code
' Handle the error here. The script will then finish.
' The error is handled by send an entry named "Error" to the TP log giving the name of the script and the number and description of the error
UserCheck "Error", False, Me.Name & Err.Number & Err.Description
End Sub </pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">