经常因为殊字符的问题导致查询异常
来源:互联网 发布:淘宝实时交易额 编辑:程序博客网 时间:2024/04/29 22:49
在日常的数据库软件开发中,有一些个特殊字符挺烦人。
比如 ' (单引号),如果有这个字符内就会有问题。在构建SQL语句的时间就要特殊处理它。
为了解决这个问题当然还有其它的方法,在这里我想从根源上解决,就是在保存数据时就自动替换为全角字符
function PUBF_ConvertSpecialChar(const s:string):string;var nlength,i:integer; str,ctmp,c1:string;begin nlength:= length(s); if (nlength = 0 ) then exit; str:= '' ; ctmp:= s; i:= 1 ; while (i <= nlength) do begin c1:= ctmp[i]; case ord(c1[1]) of// 32..48,58..64,91..96,123..127: 33..48,58..64,91..96,123..127: //不包含空格 begin str:= str + #163+ chr(ord(c1[1]) + 128 ); end else str:= str + c1; end; inc(i); end; result:= str;end;
function PUBF_ConvertFullWidthChar(const TblName: TDataSet; AFn: string): Boolean;var OrgS,DstS:string;begin Result :=True; if not TblName.Active then Exit; if TblName.STATE in [dsEdit,dsInsert] then TblName.Post; if Trim(AFn)='' then Exit; try OrgS:= TblName.FieldByName(AFn).AsString; if Trim(OrgS)='' then Exit; DstS:= PUBF_ConvertSpecialChar(OrgS); if OrgS = DstS then Exit; MsgBox(Format(MSG_CHAR_Invalid,[OrgS,DstS])); with TblName do begin if not (STATE in [dsEdit,dsInsert]) then Edit; FieldByName(AFn).AsString := DstS ; end; except on e:Exception do begin ShowErrorMessage(e.Message); Result := False; end; end;end;
- 经常因为殊字符的问题导致查询异常
- 请求Http时可能因为字符问题导致错误的特殊字符转码
- hive partition字段异常字符导致的问题
- ORACLE在使用distinct可能因为查询的列过少导致数据丢失的问题
- React-native 中因为计时器导致的异常解决办法
- Android因为Application导致的空指针异常
- Xcode因为证书问题经常报的那些错
- Xcode因为证书问题经常报的那些错
- Xcode因为证书问题经常报的那些错
- Xcode因为证书问题经常报的那些错
- Xcode因为证书问题经常报的那些错
- Xcode因为证书问题经常报的那些错
- Xcode因为证书问题经常报的那些错
- Xcode因为证书问题经常报的那些错
- Xcode因为证书问题经常报的那些错
- Xcode因为证书问题经常报的那些错
- Xcode因为证书问题经常报的那些错
- Xcode因为证书问题经常报的那些错
- Html 中的 JS 访问
- EasyUI——常见用法总结
- Linux Kernel open-time Capability file_ns_capable() Privilege Escalation
- ABAP将内表行列转换实例(动态内表)
- 免费才是王道:盘点开发者须知的25个免费数据可视化工具
- 经常因为殊字符的问题导致查询异常
- Jbpm4的IOC容器
- cocos2d-x 音乐音效
- 阿里巴巴离职DBA 35岁总结的职业生涯
- afinal 的部分使用总结
- Xlib: connection to "0.0" refused by server
- C/C++中函数参数传递详解
- 6种穷人思维必须警惕
- .NET 2.0中容易误用高级特性