Weird problem with an SQL exception truncate string or binary data

Go To StackoverFlow.com

1

I'm currently building an app for my work, it work perfectly on my PC but one i put the compile code on to the 2008 server with sqlserver 2005 and run it i get an sql error truncat data.

The weird part is that it aim the same table in the same database and it try to send to same datas.

Any one has an idea?

the error:

Unhandled Exception: System.Data.SqlClient.SqlException: String or binary data w
ould be truncated.
The statement has been terminated.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolea
n breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObj
ect stateObj)
   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cm
dHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, Tds
ParserStateObject stateObj)
   at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
   at System.Data.SqlClient.SqlDataReader.get_MetaData()
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, Run
Behavior runBehavior, String resetOptionsString)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBe
havior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehav
ior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult
 result)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehav
ior, RunBehavior runBehavior, Boolean returnStream, String method)
2009-06-16 08:56
by Polo
Can you give the exact error message you receive - Ronald Wildenberg 2009-06-16 09:01


0

I had to run the remote debugger on the server and the stupid account was 1 char to big for the table login.lenght = 16 table table_login(varchar15)...

2009-06-16 10:56
by Polo


3

Can you give any indication what you are doing at this point? One option would be i18n issues - i.e. does the 2008 server have different regional settings to your machine? this might mean that you are building some TSQL that is different (for example, formatting a date differently), and it no longer fits in the specified field (varchar(10), for example, will take some date formats but not others). Of course, the real fix here is to use a datetime - but this is just an example!

I think your best bet comes from doing a sql trace using the sql development tools; this will make it obvious what is actually being sent.

2009-06-16 09:03
by Marc Gravell


2

Run the SQL Server Profiler to make sure you are really sending the same data. It should become apparent quite quickly that one of your assumptions is wrong.

2009-06-16 09:02
by RichardOD


1

Check the default values of table or triggers. For example, inserted user name (suser_name) or host name (host_name) values may vary on different servers. And one of them may be incompatible with field size.

2009-06-16 09:05
by mucit


0

Make sure your table definition ad your stored procedure definitions are the same. I.e if you declared pro_id as varchar(10) the stored procedure should also have the same definition of varchar(10)

2010-02-12 09:36
by sa.
Ads