Purpose
Executes an SQL statement and returns a cursor if applicable.
Syntax
DBStatement.ExecuteSQL (Query)
Compliance:
Core level
Example
The following example opens a connection on a data source, opens a statement on a connection, and runs a query to determine if a particular record exists. If the record exists, customer information is displayed. Otherwise, a warning is displayed.
Sub Main()
Dim cnct As DBConnection
Dim stmt As DBStatement
cnct.OpenConnection("MyDSN") 'Open the data source "MyDSN"
stmt.OpenStatement(cnct, dbKeyset, dbRowver)
stmt.ExecuteSQL("SELECT * FROM MyTable WHERE CustNum = 12345")
If (stmt.Empty) Then 'If no records were returned
Print "The customer does not exist in the database!"
Else
Print "Customer Information:"
Print "Customer Name:"; stmt.Column("CustName")
Print "Customer Phone:"; stmt.Column("CustAddr")
Print "Customer Last Contacted:";
stmt.Column("CustLastContact")
End If
stmt.CloseStatement
cnct.CloseConnection 'Close the connection
End Sub
|