I just wanted to check here before I file a bug report.
This code, taken almost exactly from the Language Reference, works perfectly…
Var db As New SQLiteDatabase
Try
db.Connect
db.ExecuteSQL("CREATE TABLE Persons(Name, Age)")
Var ps As SQLitePreparedStatement = _
db.Prepare("INSERT INTO Persons (Name, Age) VALUES (?, ?)")
ps.BindType(0, SQLitePreparedStatement.SQLITE_TEXT)
ps.BindType(1, SQLitePreparedStatement.SQLITE_INTEGER)
ps.ExecuteSQL("john", 20)
ps = db.Prepare("SELECT * FROM Persons WHERE Name = ? AND Age >= ?")
ps.BindType(0, SQLitePreparedStatement.SQLITE_TEXT)
ps.BindType(1, SQLitePreparedStatement.SQLITE_INTEGER)
Var rs As RowSet = ps.SelectSQL("john", 20)
For Each row As DatabaseRow In rs
MessageBox("Name: " + row.Column("Name").StringValue + _
" Age: " + row.Column("Age").StringValue)
Next
rs.Close
Catch error As DatabaseException
MessageBox("Database Error: " + error.Message)
End Try
This code, which simply passes the exact same data but in the form of an array, does not.
Var db As New SQLiteDatabase
Try
db.Connect
db.ExecuteSQL("CREATE TABLE Persons(Name, Age)")
Var ps As SQLitePreparedStatement = _
db.Prepare("INSERT INTO Persons (Name, Age) VALUES (?, ?)")
Var types() As Integer = Array( _
SQLitePreparedStatement.SQLITE_TEXT, _
SQLitePreparedStatement.SQLITE_INTEGER _
)
ps.BindType(types)
Var values() As Variant = Array( "john", 20 )
ps.Bind(values)
ps.ExecuteSQL
ps = db.Prepare("SELECT * FROM Persons WHERE Name = ? AND Age >= ?")
ps.BindType(0, SQLitePreparedStatement.SQLITE_TEXT)
ps.BindType(1, SQLitePreparedStatement.SQLITE_INTEGER)
Var rs As RowSet = ps.SelectSQL("john", 20)
For Each row As DatabaseRow In rs
MessageBox("Name: " + row.Column("Name").StringValue + _
" Age: " + row.Column("Age").StringValue)
Next
rs.Close
Catch error As DatabaseException
MessageBox("Database Error: " + error.Message)
End Try
It gives me the following error…
2 parameters are being bound, but only 1 types were specified
Clearly, two BindTypes are being specified. Why is it only getting one of them?
PreparedSQLStatement.BindType(types() As Integer)
Supported for all project types and targets.
Specify types for multiple bind values. Each Database plug-in will have its own values.