Um de nossos aplicativos relata a mensagem de erro 2628:
string or binary data would be truncated in table '******', column '******'. Truncated value: '******'
ao invés de
String or binary data would be truncated in table 'mytable', column 'mycolumn'. Truncated value: 'myvalue'.
que eu recebo com SSMS.
Que configuração preciso alterar para obter a mensagem completa?
Tentei procurar por isso, mas tudo o que consigo é que preciso definir VERBOSE_TRUNCATION_WARNINGS como ON e compatibility_level como 150. O que fiz há muito tempo.
O aplicativo tem este manipulador de erros:
try
{
ES.isWorking = true;
Worker worker = new Worker(new DBConnection(Settings.ConnectionString));
worker.DoWork();
ES.isWorking = false;
}
catch (Exception ex)
{
ES.isWorking = false;
this.eventLog.WriteEntry("In OnTimer exception ! message: " + ex.Message.ToString());
errorHandler.HandleException(ex, "In OnTimer exception !", ErrorSeverities.Error);
}
O errorHandler se parece com isso
Public Function HandleException(ByVal incommingEx As System.Exception,
ByVal note As String,
ByVal errorSeverity As ErrorSeverities,
Optional ByVal sessionId As String = "",
Optional ByVal applicationSource As String = "",
Optional ByVal ignoreDB As Boolean = False,
Optional ByVal noMail As Boolean = False) As Integer
Dim stackTraceBuilder As New System.Text.StringBuilder
Dim targetSite As String = ""
Dim errorTime As DateTime = Now
Dim messageBuilder As New System.Text.StringBuilder
Dim innerEx As Exception = incommingEx.InnerException
Dim errorId As Integer = 0
Dim innerCount As Integer = 1
Dim loggedToDb As Boolean = False
Dim appSource As String = Me._applicationSource
If applicationSource <> "" Then
appSource = applicationSource
End If
'... more code'
messageBuilder.AppendLine("(" + incommingEx.GetType.Name.ToUpper + ")" + vbCrLf + incommingEx.Message + " - SOURCE: " + incommingEx.Source)
'...'
While Not innerEx Is Nothing And innerCount <= 5
messageBuilder.AppendLine("INNER" + Convert.ToString(innerCount) + " (" + innerEx.GetType.Name.ToUpper + "):" + vbCrLf + **innerEx.Message** + " - SOURCE: " + innerEx.Source)
If Not innerEx Is Nothing AndAlso Not innerEx.StackTrace Is Nothing Then
stackTraceBuilder.AppendLine("INNER" + Convert.ToString(innerCount) + ": " + innerEx.StackTrace) 'Me.GetNumberedStack(innerEx))
End If
innerEx = innerEx.InnerException
innerCount += 1
End While
'... more code where the error message is inserted in a log table, via a sproc'
End Function
Não vimos esse comportamento antes, mas atualizamos recentemente o framework .net para a versão 4.7.2, para que possa estar relacionado.
o texto de erro "string ou binário" está vindo do bit que vai
- innerEx.Message + e esse é um tipo de dados Exception interno simples. Portanto, é VB e/ou .net e/ou SQL Server que está construindo a string, não nós.
O erro ocorre após uma chamada para um procedimento armazenado, onde o usuário provavelmente digitou um texto varchar(1000). O procedimento armazenado adiciona um pouco mais e a tabela não tem espaço para todos os 1100 bytes. Daí o erro. O procedimento armazenado não tem um bloco try-catch.