PdcDatabase.OpenQuery: Difference between revisions

From External Bemet Wiki
Jump to navigation Jump to search
Created page with "== Declaration == OpenQuery(Connection as pdcConnectionKind) as PdcDBQuery == Description == Return a IDBQuery for execution == Notes == This method opens a query for a..."
 
Line 23: Line 23:
       qryCustomer.FirstRecord
       qryCustomer.FirstRecord
       msgbox "The first customer is '" & qryCustomer.GetField("KL_NAAM") & "'."
       msgbox "The first customer is '" & qryCustomer.GetField("KL_NAAM") & "'."
             intTel = 0
             intTel = 0
       do while not qryCustomer.Eof
       do while not qryCustomer.Eof
Line 29: Line 28:
           intTel = intTel + 1
           intTel = intTel + 1
         end if
         end if
                 qryCustomer.NextRecord
                 qryCustomer.NextRecord
       loop
       loop
             msgbox intTel & " customers found in Amsterdam."
             msgbox intTel & " customers found in Amsterdam."
     else
     else
Line 42: Line 39:
</source>
</source>


For more help about the SQL language see the helpfile of Advantage.  
For more help about the SQL language see the helpfile of Advantage.


== Availability ==
== Availability ==
Available since September 2008 (from version 3.8)
Available since September 2008 (from version 3.8)

Revision as of 09:55, 22 May 2012

Declaration

OpenQuery(Connection as pdcConnectionKind) as PdcDBQuery

Description

Return a IDBQuery for execution

Notes

This method opens a query for a specified SQL statement. The result set of records is available as a table. The input parameter is a connectionkind.

Code example

dim qryCustomer
dim intTel

  set qryCustomer = pdc.Database.OpenQuery(pdccondata)
  qryCustomer.SQL = "SELECT * FROM LK_KLANT WHERE ((KL_SOORT = 'K') OR (KL_SOORT = 'B')) ORDER BY UCase(KL_NAAM)"

    if qryCustomer.Execute then
    if qryCustomer.RecordCount > 0 then
      qryCustomer.FirstRecord
      msgbox "The first customer is '" & qryCustomer.GetField("KL_NAAM") & "'."
            intTel = 0
      do while not qryCustomer.Eof
        if UCase(Trim(qryCustomer.GetField("KL_PLAATS"))) = "AMSTERDAM" then
          intTel = intTel + 1
        end if
                qryCustomer.NextRecord
      loop
            msgbox intTel & " customers found in Amsterdam."
    else
      msgbox "There are no records found in the result set."
    end if
  else
    msgbox pdc.LastError
  end if

For more help about the SQL language see the helpfile of Advantage.

Availability

Available since September 2008 (from version 3.8)