MBS SQLSelect using Prepared Statement

I have not find documentatio to make a select using prepared statement
these examples demostrates only insert but not select

i have try this code but its not work, anyone has a documentation ?

dim r1 as RowSet
dim cmd as new SQLCommandMBS
cmd.Connection=db ’ db is a valid and istantiated db SQLdatabaseMBS connection
cmd.setCommandText("select * from allegati where id= value(:1) ")
cmd.Param(1).setAsInteger(119)
cmd.Execute
r1=cmd.AsRowSet

the rowset result nil, the record with id = 119 is existent

no idea why you use SQLCommandMBS where you started with SQLDatabaseMBS and you asked for the SQLPreparedStatementMBS class.

let’s change an insert to select

Var db as SQLDatabaseMBS // your db connection
Var sql as string = "SELECT * FROM MyTable WHERE id = :fid "
Var v as Variant = db.Prepare(sql)
Var p as SQLPreparedStatementMBS = v

p.BindType("fid", SQLPreparedStatementMBS.kTypeLong)
p.Bind("fid", 2345)

var r as RowSet = p.SelectSQL

Something like this may work.

But you could also just call SelectSQL directly on the database object.

1 Like

Im Sorry, i have started to use your plugin Just now so i dont know It, i brutally Copied the examples code of your examples files and i cannot find any example Or documetation that says how to do what i ask.
Thank you for yout suggestions, i Will try this.

its work, thank you Christian

1 Like

Are you using the full prepared statement code or:

I have used the code that Christian has suggested in the last comment