ALM Site Administration API Type Library
RunQuery Method
Runs the SQL statement on the project database and retrieves results.
Visual Basic
Public Function RunQuery( _
   ByVal DomainName As String, _
   ByVal ProjectName As String, _
   ByVal SqlQuery As String, _
   ByVal MaxRecords As Long, _
   ByVal FromRecord As Long _
) As String
The domain name.
The project name.
The SQL statement.
The maximum number of records to return.

Return records from this record to the end of the record set.  For example, if FromRecord is 8, records 0 to 7 are not returned. All records from the ninth (index = 8) on are returned.

Return Type
On success, returns an XML string containing selected records according to the SQL statement. ColumnLables show all columns, numbers, and names. DataRows show all the rows that return results. For each row that returns results, only the columns containing data are returned.
Return Value Details

In both <ColumnLables> and <Rows>, the tag <_n> indicates the column number in the SQL results.

In <ColumnLables>, the text of the element is the name of the column.

In <Rows>, the text of the element is the value of the column.

Return Value Example
                <_5>Not Reviewed</_5>
                <_7>Not Covered</_7>
                <_11>Requirement 1</_11>
                <_31>2002-09-02 14:15:03</_31>
                <_5>Not Reviewed</_5>
                <_7>Not Covered</_7>
                <_11>Requirement 2</_11>
                <_31>2002-09-02 14:13:57</_31>
Private Sub RunQuery()

'The following Visual Basic example runs an SQL statement
' showing the first 25 row results.
    Dim sDomainName As String
    Dim sProjectName As String
    Dim sSql As String
    Dim sReply As String

    On Error GoTo err
    sDomainName = "MyDomain"
    sProjectName = "MyProject"
    sSql = "SELECT * FROM REQ"
    sReply = m_SAClient.RunQuery _
        (sDomainName, sProjectName, sSql, 25, 0)

    MsgBox sReply
    Exit Sub
    MsgBox "Program failed:" + err.Description
End Sub
See Also