转至繁体中文版     | 网站首页 | 图文教程 | 资源下载 | 站长博客 | 图片素材 | 武汉seo | 武汉网站优化 | 
最新公告:     敏韬网|教学资源学习资料永久免费分享站!  [mintao  2008年9月2日]        
您现在的位置: 学习笔记 >> 图文教程 >> 软件开发 >> Delphi程序 >> 正文
Delphi7中存储unicode的BUG?         ★★★★

Delphi7中存储unicode的BUG?

作者:闵涛 文章来源:闵涛的学习笔记 点击数:1498 更新时间:2009/4/23 18:26:59

Delphi7中存储unicodeBUG

 

近日,在用delphi7unicode的程序时发现了这样一个问题,就是使用TADOCommand组件执行sql语句时,如果sql语句中有unicode字符,存储在数据库里会出现乱码,使用TTntADOQuery也是一样(使用参数方式不会出现乱码,这里只讨论纯sql的方式)。但是TADOCommand本身是支持widestring的呀,CommandText属性也是widestring类型的,为什么会出现这个问题呢?我试着改变TADOCommand的几个属性值,发现了一个怪现象,只要把ParamCheck属性置为false就可以正常的存储unicode字符,而置为true时就出现乱码。为什么会出现这种情况?这个属性看起来和unicode本身没有任何关系,究竟是什么原因导致了乱码的发生呢?我通过研究TADOCommand所在的adodb.pas文件,发现了问题的所在,我们看一下bug所在的过程:

procedure TADOCommand.AssignCommandText(const Value: WideString; Loading: Boolean);

 

  procedure InitParameters;

  var

    I: Integer;

    List: TParameters;

    NativeCommand: string;

  begin

    List := TParameters.Create(Self, TParameter);

    try

      NativeCommand := List.ParseSQL(Value, True);

      { Preserve existing values }

      List.AssignValues(Parameters);

      CommandObject.CommandText := NativeCommand;

      if not Loading and (Assigned(Connection) or (ConnectionString <> '''''''')) then

      begin

        try

          SetConnectionFlag(cfParameters, True);

          try

            { Retrieve additional parameter info from the server if supported }

            Parameters.InternalRefresh;

            { Use additional parameter info from server to initialize our list }

            if Parameters.Count = List.Count then

              for I := 0 to List.Count - 1 do

              begin

                List[I].DataType := Parameters[I].DataType;

                List[I].Size := Parameters[I].Size;

                List[I].NumericScale := Parameters[I].NumericScale;

                List[I].Precision := Parameters[I].Precision;

                List[I].Direction := Parameters[I].Direction;

                List[I].Attributes := Parameters[I].Attributes;

              end

          finally

            SetConnectionFlag(cfParameters, False);

          end;

        except

          { Ignore error if server cannot provide parameter info }

        end;

        if List.Count > 0 then

          Parameters.Assign(List);

      end;

    finally

      List.Free;

    end;

  end;

 

[1] [2]  下一页


[聊天工具]小心Foxmail邮件模板BUG  [聊天工具]OICQ---存在重大BUG?
[系统软件]Explanation of UFT-8 and Unicode  [系统软件]Windows记事本中的Bug
[常用软件]解决压缩软件的Bug技巧  [VB.NET程序]在 VB 中使用 Unicode API
[Delphi程序]Delphi 6 SOAP 源码中的BUG修正  [Delphi程序]改良控件-Delphi自带控件Bug的消除
[Delphi程序]不知您是笨蛋,还是我是笨蛋,关于Delphi的大Bug  [Delphi程序]关于Delphi大Bug的更详细的例子
教程录入:mintao    责任编辑:mintao 
  • 上一篇教程:

  • 下一篇教程:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
      注:本站部分文章源于互联网,版权归原作者所有!如有侵权,请原作者与本站联系,本站将立即删除! 本站文章除特别注明外均可转载,但需注明出处! [MinTao学以致用网]
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)

    同类栏目
    · C语言系列  · VB.NET程序
    · JAVA开发  · Delphi程序
    · 脚本语言
    更多内容
    热门推荐 更多内容
  • 没有教程
  • 赞助链接
    更多内容
    闵涛博文 更多关于武汉SEO的内容
    500 - 内部服务器错误。

    500 - 内部服务器错误。

    您查找的资源存在问题,因而无法显示。

    | 设为首页 |加入收藏 | 联系站长 | 友情链接 | 版权申明 | 广告服务
    MinTao学以致用网

    Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved.
    闵涛 投放广告、内容合作请Q我! E_mail:admin@mintao.net(欢迎提供学习资源)

    站长:MinTao ICP备案号:鄂ICP备11006601号-18

    闵涛站盟:医药大全-武穴网A打造BCD……
    咸宁网络警察报警平台