Recent

Author Topic: MSSQLConnection - raised stored procedure errors not being recorded  (Read 2712 times)

bitsnbytez

  • Newbie
  • Posts: 1
I am using Lazarus together with TMSSQLConnector and TSQLQuery to connect to a SQL Server 2012 database and execute stored procedures. I have found that errors raised in a stored procedure (from missing parameters or an exception raised from the invocation of the stored procedure itself) are not made visible to the calling code.

When stepping through mssqlconn.pp, I can see the error being raised during the execution of the following routine:

procedure TMSSQLConnection.Execute(const cmd: string);
begin
  DBErrorStr:='';
  DBMsgStr  :='';
  CheckError( dbcmd(FDBProc, PChar(cmd)) );
  CheckError( dbsqlexec(FDBProc) );
  CheckError( dbresults(FDBProc) );
end;
And is passed back via the DBMsgHandler function.

However, the DBMsgStr that is built up is never evaluated as the dbsqlexec call does not appear to return a FAIL code.

Because DBMsgStr is not public, I am not able to evaluate it from the outside (nor would I want to as this raises threading concerns).

To reproduce, create a stored procedure that requires a parameter. Invoke the stored procedure by setting the SQL property of a TSQLQuery object to 'EXEC "proc name"' and calling ExecSQL (without adding the parameter to the SQL statement).

I am using ftp://ftp.freepascal.org/fpc/contrib/windows/dblib_0.91.zip (32-bit) build of the driver to connect to the SQL server.

LacaK

  • Hero Member
  • *****
  • Posts: 691
Re: MSSQLConnection - raised stored procedure errors not being recorded
« Reply #1 on: November 28, 2014, 11:16:29 am »
Sorry, for late reply, but this problem is already fixed in TRUNK.

 

TinyPortal © 2005-2018