1

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?

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
James L.
  • 9,384
  • 5
  • 38
  • 77
  • You could get hacky and edit the component source but I would not recommend this. You should try and accept the limitation. Not many errors would exceed 256 unless they include an sql reference and surely you know where you are in your program. Sorry its not the answer you were hoping for and good luck. – Reallyethical Apr 28 '12 at 07:05
  • I've already looked at the component source. It seems to be an external call to get the error's MessageLength, so I don't think there's much I can do unless there's a property in the DBXDrivers.ini file (or the like)... I am wrapping the SQL error with a more user-friendly error. Together they exceed the 256 characters. That's why I want to extend the limit to something like 512. – James L. Apr 28 '12 at 07:12
  • 1
    I would have thought your question is a duplicate of the question ["Reconcile Error: Has anyone had problems with truncated error messages?"](http://stackoverflow.com/questions/8701752). But your analysis highly differ with [the analysis](http://stackoverflow.com/a/8716605/243614) of that question/answer's author. So I'm not sure.. – Sertac Akyuz Apr 29 '12 at 01:09
  • 1
    Thanks for the link. I read through it and I believe Carlos was dealing with the same underlying problem. I suspected the midas.dll as well. I believe his explanation is the answer that I was looking for. Thanks Sertac! – James L. Apr 29 '12 at 03:47
  • @James - You're welcome!.. It's a pity that the developers feel that one have to be content with what they chose to be appropriate, while coding otherwise would be no big deal. – Sertac Akyuz Apr 29 '12 at 12:45
  • @Sertac - If you convert your comment to an answer, I'll be happy to mark it correct. – James L. Apr 30 '12 at 13:20
  • @James - Please you do that, I'm not familiar with internals of DBX at all. – Sertac Akyuz Apr 30 '12 at 14:00

1 Answers1

1

@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?

Community
  • 1
  • 1
James L.
  • 9,384
  • 5
  • 38
  • 77