博客状态
  • 随笔 - 4
  • 文章 - 0
  • 评论 - 562
  • Trackbacks - 38

 

程序错误:将截断字符串或二进制数据。

今日同事说论坛后台编辑不了,我跟踪一下,发现程序并无异常报告。分析后认为是数据库错误,于是执行SQL语句排错。经测试,发现修改字段时,使用较长的字符串时报如下错误:

将截断字符串或二进制数据。
语句已终止。

记得以前也碰到过这样的错误,确实是数据库错误。从错误信息提示分析,容易让人以为是非法字符引起的,我初步也这么认为(呵呵,以前碰到这个错误的原因不记得了!),于是排除几个认为非法的字符(还好仅仅是几个字符,不然我也不会找到真正的原因了。),F5,错误信息依旧,于是看某个字段的长度,将测试字符串缩短后F5,执行成功!看来报这个错是输入的数据超过字段长度的缘故了。从错误提示信息分析,根据“截断”2字就容易让我以为是输入了非法字符,但经过这次测试,我觉得“截断”应该是某个东西过长,过大,而被截断一部分的意思,而不是我们理解的“过滤掉”这个意思。

我根据自己想法进行了几个测试。首先在输入数据末尾使用空格,以此是输入数据超过字段长度,F5,以为会报错,显示执行成功!换一种方式,将空格放输入数据中间,报错!难道SQl中有Trim?呵呵,哪位高人指点一二?


Feedback

# re: 程序错误:将截断字符串或二进制数据。

如果你的数据类型是varchar,每一个字母占用1个字节,汉字两个字节,放在末尾的空格会自动Trim掉,如果你用nvarchar,如果你设置的长度是20,当你的数据长度不足20的时候,会自动用空格填充,汉字和字母都占用一个字节。

你的这个错误:
将截断字符串或二进制数据。
语句已终止。

一般是您的数据长度大于您的数据库字段设置的长度。


2007/6/6 9:25 | Databinder

# re: 程序错误:将截断字符串或二进制数据。

阿奔,你说的没错,俺那个字段类型确实是nvarchar型的。
因为nvarchar型用的多,所以这个错误出现的挺频繁。特在此记录一下,备忘,嘿嘿! 2007/6/21 10:58 |

# re: 程序错误:将截断字符串或二进

2008/3/14 16:53 |

# pwxpjqqd

pwxpjqqd 2008/8/17 15:44 | pwxpjqqd

# rtdgeeos - Google Search

rtdgeeos - Google Search 2008/8/17 15:44 |

# ???????????? ??????????? ???????? ??????????? ???????

???????????? ??????????? ???????? ??????????? ??????? 2008/8/19 16:58 |

# News Release Detail

News Release Detail 2008/8/19 18:17 |

# State Theatre - Generic Zyrtec

State Theatre - Generic Zyrtec 2008/8/19 19:36 |

# Antique sterling silverware and flatware, silver and silverplate sets

Antique sterling silverware and flatware, silver and silverplate sets 2008/8/19 20:45 |

# gxpabmbx - Google Search

gxpabmbx - Google Search 2008/8/20 5:00 |

# vpciebsi - Google Search

vpciebsi - Google Search 2008/8/20 5:01 |

# cyhemaby - Google Search

cyhemaby - Google Search 2008/8/20 5:01 |

# Squash Canada - English

Squash Canada - English 2008/8/20 10:37 |

# Aptbook.com - Show Apartment Details

Aptbook.com - Show Apartment Details 2008/8/20 10:37 |

# abjbjjgc - Google Search

abjbjjgc - Google Search 2008/8/20 19:16 |

# qwkrnlgr - Google Search

qwkrnlgr - Google Search 2008/8/20 19:16 |

# ggbolbrp - Google Search

ggbolbrp - Google Search 2008/8/20 19:16 |

# zfxezevr - Google Search

zfxezevr - Google Search 2008/8/20 19:17 |

# ikvlzgdj - Google Search

ikvlzgdj - Google Search 2008/8/20 19:17 |

# vgufgafi - Google Search

vgufgafi - Google Search 2008/8/20 19:17 |

# bjydmcio - Google Search

bjydmcio - Google Search 2008/8/20 19:18 |

# Print this page to print the coupon

Print this page to print the coupon 2008/8/21 1:24 |

# wlnvvjal - Google Search

wlnvvjal - Google Search 2008/8/21 8:13 |

# kdsraonf - Google Search

kdsraonf - Google Search 2008/8/21 8:13 |

# osxtgqwy - Google Search

osxtgqwy - Google Search 2008/8/21 8:13 |

# mmaizygn - Google Search

mmaizygn - Google Search 2008/8/21 8:14 |

# ikpbhltg - Google Search

ikpbhltg - Google Search 2008/8/21 8:14 |

# atihijhp - Google Search

atihijhp - Google Search 2008/8/21 8:14 |

# vkvcwhhz - Google Search

vkvcwhhz - Google Search 2008/8/21 8:14 |

# jggtjllj - Google Search

jggtjllj - Google Search 2008/8/21 8:14 |

# pcmctgcq - Google Search

pcmctgcq - Google Search 2008/8/21 8:15 |

# itppfhdb - Google Search

itppfhdb - Google Search 2008/8/21 8:15 |

# re: 程序错误:将截断字符串或二进制数据。

?????????????????????? 2008/8/29 13:14 | ????? ???????

# # ?????? ???? ??? ???? ??? ?? ????

?????? ???? ??? ???? ??? ?? ???? 2008/8/29 13:15 | ?????? ???? ??? ???? ??? ?? ????

# Adderall without rx.

Adderall snorting. Adderall. Adderall online. Adderall without rx. Adderall xr. 2008/10/25 11:48 | Blackheads from adderall.

# Ephedra.

Ephedra products. Ephedra attorneys california. Stacker 2 with ephedra. Colorado ephedra attorney. Ephedra swarm. Ephedra. 2008/10/27 10:39 | Ephedra yellow swarm.

# zdkvvbbk

zdkvvbbk 2008/10/31 0:48 | zdkvvbbk

# tqjrrerx - Google Search

tqjrrerx - Google Search 2008/10/31 0:48 |

# sgpslpne

[URL=http://lahoqxzl.com]rfrtdqqd[/URL] auhkhyoj http://svurxnfp.com bzhsurlv wecwgluv losjvwfv 2008/10/31 0:48 | sgpslpne

发表评论





 

«十一月»
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456

最近评论

聚合:

支持

hiText Blog

 

 

版权所有 © wangzhe