Hi all,
Here is my simple test for prepared statements with MSSQL:
dim LocDB as new MSSQLServerDatabase
LocDB.Host = "DELL-WIN10"
LocDB.DatabaseName = "Test_Web"
LocDB.UserName = "sa"
LocDB.Password = "12345678"
If Not locDB.Connect Then
MsgBox("DB Connect Failure!")
else
dim Loc_Sql as string = "SELECT * FROM SystemUser WHERE GUID=?"
Dim rs as RecordSet
Dim ps as MSSQLServerPreparedStatement
ps = locdb.Prepare(Loc_Sql)
ps.BindType(0, MSSQLServerPreparedStatement.MSSQLSERVER_TYPE_INT)
ps.bind(0, 1)
rs = ps.sqlselect
If locdb.Error Then
msgbox "Error: " + locdb.ErrorMessage
else
msgbox rs.Field("UserCode").StringValue
End if
end if
This runs successfully and returns the “UserCode”. However, if I change the SQL to an invalid one like “SELECT *, FROM SystemUser WHERE GUID=?”, it does not return error but gives me an NilObjectException at rs.Field(“UserCode”).StringValue.
I tried using ODBC to connect to a firebird DB with similar test, it does return error to me. Can I say this is a bug or so?