PreparedSQLStatement.Bind

From Real Software Documentation

Jump to: navigation, search
Method
PreparedSQLStatement.Bind ( zeroBasedParam as Integer, type as Integer )

Binds a value for the prepared statement.

Use Database.Prepare to set up the bind.

Example

In the example project in the Database Example folder, the Bind method is used to bind the TextField that contains the query to the statement.

Dim stmt As REALSQLPreparedStatement

// note in a prepared statement you DONT put in the quotes
stmt = REALSQLPreparedStatement(db.Prepare("SELECT * FROM Customers WHERE FirstName like ? "))

// have to tell sqlite what types the items being bound are so it does the right thing
stmt.BindType(0, REALSQLPreparedStatement.SQLITE_TEXT)
stmt.Bind(0, textfield1.text)

// perform the search
Dim rs As RecordSet = stmt.SQLSelect

listbox1.deleteAllRows
listbox1.columnCount = rs.FieldCount
listbox1.hasHeading = true

dim hasHeadings as boolean

while rs.eof <> true
listbox1.addRow ""

for i as integer = 0 to rs.fieldcount-1
if not hasheadings then listbox1.heading(i) = rs.idxField(i+1).Name
listbox1.cell(listbox1.lastIndex, i) = rs.idxField(i+1).StringValue
next

rs.movenext
hasHeadings = true
wend
Personal tools