Azure database

I am trying to query an Azure database using MSSQLServerPreparedStatement, code below.

Dim sql As Text = "SELECT * FROM bc_form WHERE id = ?"
			
Dim ps As MSSQLServerPreparedStatement = mDB.Prepare(sql)
			
Dim rs As RecordSet
			
rs = ps.SQLSelect(id.ToText)

where id =5, I have tested using 5 in place of id.ToText, still gives me errors. I have also tried to bind using the following code.

Dim sql As Text = "SELECT * FROM bc_form WHERE id = ?"
			
Dim ps As MSSQLServerPreparedStatement = mDB.Prepare(sql)
			
ps.BindType(0, MSSQLServerPreparedStatement.MSSQLSERVER_TYPE_INT)
ps.Bind(0, id)
			
Dim rs As RecordSet
			
rs = ps.SQLSelect

However going back to just using mDB.SQLSelect works

Dim sql As Text = "SELECT * FROM bc_form WHERE id = " + id.ToText

    Dim rs As RecordSet
rs = mDB.SQLSelect(sql)

Any thoughts, thanks.

Solved. As most things we all start with an example and then try to expand.

Don’t use sql as Text, rather a string as follow

Dim sql As String = “SELECT * FROM bc_form WHERE id = ?”

This works with the prepared statements.