MySQLPreparedStatement

From Real Software Documentation

Jump to: navigation, search
Class (inherits from PreparedSQLStatement)

Used to upcast the result of a call to Database.Prepare. You must upcast it or you will get a NilObjectException.


Notes

It uses the following constants to MySQLPreparedStatement that can be used in the BindType method.

Constant
MYSQL_TYPE_BLOB
MYSQL_TYPE_DATE
MYSQL_TYPE_DATETIME
MYSQL_TYPE_DOUBLE
MYSQL_TYPE_FLOAT
MYSQL_TYPE_LONG
MYSQL_TYPE_LONGLONG
MYSQL_TYPE_NULL
MYSQL_TYPE_SHORT
MYSQL_TYPE_STRING
MYSQL_TYPE_TIME
MYSQL_TYPE_TIMESTAMP
MYSQL_TYPE_TINY

It uses the "?" character as its marker in the prepared statement, i.e.
"SELECT * FROM Persons WHERE Name = ?"
It requires the use of BindType.

Examples

This example shows how to use database binding.

// We'll assume "db" is the MySQL Database object added to your project
Dim stmt As MySQLPreparedStatement
stmt = MySQLPreparedStatement(db.Prepare("SELECT * FROM Persons WHERE Name = ? AND Age >= ?"))
stmt.Bind(0, "John")
stmt.BindType(0, MySQLPreparedStatement.MYSQL_TYPE_STRING)
stmt.Bind(1, 20)
stmt.BindType(1, MySQLPreparedStatement.MYSQL_TYPE_SHORT)

Dim rs As RecordSet = stmt.SQLSelect

See Also

Database Class, MySQLCommunityServer, PreparedSQLStatement

Personal tools