的SQLException:字符串或二进制数据将被截断 [英] SQLException : String or binary data would be truncated

查看:331
本文介绍了的SQLException:字符串或二进制数据将被截断的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C#code这确实很多INSERT语句的批处理。在执行这些语句中,我得到了字符串或二进制数据将被截断错误和交易roledback。

I have a C# code which does lot of insert statements in a batch. While executing these statements, I got "String or binary data would be truncated" error and transaction roledback.

要找出哪些INSERT语句造成这一点,我需要一个在SQLServer的插入一个,直到我打的错误。

To find out the which insert statement caused this, I need to insert one by one in the SQLServer until I hit the error.

有聪明的方法findout其中陈述和现场使用异常处理引起的这个问题? (SQLEXCEPTION)

Is there clever way to findout which statement and which field caused this issue using exception handling? (SqlException)

推荐答案

在一般情况下,没有一种方法来确定哪些特定语句导致错误。如果你正在运行的几个,你可以看探查,并期待在最后完成的声明,看看之后的声明可能是,虽然我不知道如果这种方法是可行的你。

In general, there isn't a way to determine which particular statement caused the error. If you're running several, you could watch profiler and look at the last completed statement and see what the statement after that might be, though I have no idea if that approach is feasible for you.

在任何情况下,你的参数变量(和它里面的数据)中的一个是它试图将数据存储在该领域过大。请检查您的参数大小与问题列大小和现场(S)应该是很明显pretty快。

In any event, one of your parameter variables (and the data inside it) is too large for the field it's trying to store data in. Check your parameter sizes against column sizes and the field(s) in question should be evident pretty quickly.

这篇关于的SQLException:字符串或二进制数据将被截断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆