SQLExecQuery (function)

Syntax

SQLExecQuery(ID, query$)

Description

Executes an SQL statement query on a data source.

Comments

This function is called after a connection to a data source is established using the SQLOpen function. The SQLExecQuery function may be called multiple times with the same connection ID, each time replacing all results.

The following table describes the parameters to the SQLExecQuery function:

 

Parameter

Description

 

ID

Long identifying a valid connected data source. This parameter is returned by the SQLOpen function.

 

query$

String specifying an SQL query statement. The SQL syntax of the string must strictly follow that of the driver.

 

The return value of this function depends on the result returned by the SQL statement:

 

SQL Statement

Value

 

SELECT...FROM

The value returned is the number of columns returned by the SQL statement.

 

DELETE,INSERT,UPDATE

The value returned is the number of rows affected by the SQL statement.

 

The Basic Control Engine generates a runtime error if SQLExecQuery fails. Additional error information can then be retrieved using the SQLError function.

Example

This example executes a query on the connected data source.

Sub Main()
  Dim s As String
  Dim qry As Long
  id& = SQLOpen("dsn=SAMPLE",s$,3)
  qry = SQLExecQuery(id&,"Select * From c:\sample.dbf")
  MsgBox "There are " & qry & " columns in the result set."
  id& = SQLClose(id&)
End Sub

See Also

SQLOpen (function); SQLClose (function); SQLRetrieve (function); SQLRetrieveToFil (function)

 

 

 

 

More information

S