Question

I'm using Delphi-XE2 Enterprise, SQLServer 2008 R2 on Windows Server 2008 R2. When a SQL error is raised, the DataSnap server captures it and returns it to the client application. This all works, except the error message it truncated to 256 characters.

A stack track of the DataSnap server when the error is raised shows the SQL error message is truncated when the SQL DB Error is retrieved through the DBX Framework using the [file:Data.DBXDynalink]TDBXMethodTable.RaiseError() method. The following line of code from the RaiseError() method sets the MessageLength to 256, even when the error message is longer. Thus the error message returned to the client is never longer than 256 characters.

Status := FDBXBase_GetErrorMessageLength(DBXHandle, DBXResult, MessageLength);

FDBXBase_GetErrorMessageLength is of type TDBXCommon_GetErrorMessageLength, which is defined as:

TDBXCommon_GetErrorMessageLength = function(Handle: TDBXCommonHandle; LastErrorCode: TDBXErrorCode; out ErrorLen: TInt32): TDBXErrorCode; stdcall;

Is there a way to increase the buffer size to allow more of the database error to be sent to the client (e.g., 512 characters), or is this just a limitation of the DBX Framework?

Was it helpful?

Solution

@Sertac found a very similar problem that Carlos had with a driver truncating the error messages. Carlos found that changing the midas.dll to increase the error buffersize fixed his problem. I'm sure the solution is the same for my issue.

Thanks @Sertac for providing the link to Carlos' question:

Reconcile Error: Has anyone had problems with truncated error messages?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top