ODBCPreparedStatement

From Xojo Documentation

Revision as of 16:37, 31 July 2012 by PLefebvre (talk | contribs) (Created page with '<ShowIf version=2012r1> {{ClassBox | super=PreparedSQLStatement | platform=all | scope=global }} {{Description |text = ODBCPreparedStatement is used to upcast the result of a…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Class (inherits from PreparedSQLStatement)

ODBCPreparedStatement is used to upcast the result of a call to Database.Prepare by the ODBCDatabase class. You must upcast it or you will get a NilObjectException when you attempt to use the resulting prepared statement.


Properties

Notes

Use the "?" character as the parameter marker in the prepared statement ("SELECT * FROM Persons WHERE Name = ?").

Examples

This example shows how to use database binding.

// Assume "db" is an ODBC Database object
Dim ps As ODBCPreparedStatement
ps = ODBCPreparedStatement(db.Prepare("SELECT * FROM Persons WHERE Name = ? AND Age >= ?"))
stmt.Bind(0, "John")
stmt.Bind(1, 20)

Dim rs As RecordSet = ps.SQLSelect


Alternatively, you can avoid binding the types manually with the Bind method by supply the values as part of the SQLSelect call:

// Assume "db" is an ODBC Database object
Dim ps As ODBCPreparedStatement
ps = ODBCPreparedStatement(db.Prepare("SELECT * FROM Persons WHERE Name = ? AND Age >= ?"))
rs = stmt.SQLSelect("John", 20)


See Also

Database Class, ODBCDatabase, PreparedSQLStatement classes.