Groups | Blog | Home
all groups > sql server programming > september 2004 >

sql server programming : Need help with string truncation


tony c
9/5/2004 9:37:26 PM

Hi,
I am using vb.net and am using a table to capture exceptions which
occur in my program. When I try to store the "exception.tostring()"
function - it gives me a string of length 277 which when stored in my
talbe gets truncated to around 100 characters. I see the whole string
going in with the profiler. Any ideas as to what I'm missing?


CREATE TABLE [dbo].[ErrorLog] (
[intLogNo] [numeric](18, 0) IDENTITY (1, 1) NOT NULL ,
[strMessage] [varchar] (500) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[strStackTrace] [varchar] (500) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[strTargetSite] [char] (100) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[dtTimeStamp] [datetime] NULL ,
[strType] [char] (200) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL
) ON [PRIMARY]
GO


Dan Guzman
9/5/2004 9:58:21 PM
If you are viewing the data with Query Analyzer, check the maximum
characters specification under Tools --> Options --> Results.

--
Hope this helps.

Dan Guzman
SQL Server MVP
[quoted text, click to view]

tony c
9/5/2004 10:10:42 PM
Sorry Guys,

I guess I FINALLY (after about 4 hours) figured it out.

It was the stored procedure I was using to insert the
data with. I have just discovered how nice the stored procedure
wizard is for doing some things and I guess I didn't pay that
much attention to the code. I had changed the table size but
didn't realize, or forgot to check and change the stored procedure
to match the new table changes. Well here is what it looked like:

CREATE PROCEDURE [insert_ErrorLog]
( @strMessage_2 [char](100), <----***
@strStackTrace_3 [char](100), <----***
@strTargetSite_4 [varchar](100),
@dtTimeStamp_5 [datetime],
@strType_6 [char](200))

AS INSERT INTO [tavern].[dbo].[ErrorLog]
( [strMessage],
[strStackTrace],
[strTargetSite],
[dtTimeStamp],
[strType])

VALUES
( @strMessage_2,
@strStackTrace_3,
@strTargetSite_4,
@dtTimeStamp_5,
@strType_6)
GO


And I'm wondering my my strings are getting truncated.
DUH... :) But posting this helped me to take another look at it.
tony c
9/5/2004 10:12:35 PM
Thanks Dan,
Sorry to have buged you. Maybe that's what I get for
watching TV while I'm programming.


AddThis Social Bookmark Button