Advertising banner:

History
 
 Statement.OpenStatement
Home • Help • A0 • Customization Tools • FCAS • Language Reference • Statement.OpenStatement
 
OpenStatement (database statements)
Purpose
Opens a statement on a database connection.
Syntax
DBStatement.OpenStatement (CnctName [, dbCursorType] [, dbConcurrency])


CnctName
Specifies the name of a valid DBConnection object that has already opened a connection on a valid data source.
dbCursorType
The statement's cursor type.
This provides an effective shortcut to setting the cursor type explicitly with the CursorType attribute.
The cursor type can be one of the following constants:
dbForwardOnly
Forward-only cursor. This is the default
dbStatic
Static cursor.
dbKeyset
Keyset-driven cursor.
dbDynamic
Dynamic cursor.
dbConcurrency
The statement's concurrency.
This provides an effective shortcut to setting the concurrency explicitly with the Concurrency attribute.
The concurrency can be one of the following constants:
dbReadOnly
Cursor is read only. This is the default.
dbLock
Cursor uses row-level locking concurrency.
dbValues
Cursor uses optimistic concurrency, comparing values.
dbRowver
Cursor uses optimistic concurrency, comparing row versions.

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