我在程序中需要将integer转换成char,然后入库(Mysql),我的语句是: ScheduleOne^.Sender^.TerminalType:= chr(TerminalTypeComb1.ItemIndex+1); TerminalType的定义是:TerminalType : Char; 程序编译没有问题,调试时TerminalType的值为 #1,即数字前总有#,入库后显示的不是1,而是一个矩形框。请问我该怎么写啊?

解决方案 »

  1.   

    ... := IntToStr(TerminalTypeComb1.ItemIndex+1)[1];
      

  2.   

    你在Mysql中的字段类型是怎样定义的
      

  3.   

    如果是char你的TerminalType应该定义成string类型
      

  4.   

    TerminalType 在数据库中的定义是:varchar(1)
      

  5.   

    function inttochar( int_char:integer):char;
      begin
        case int_char of
          1 : result:='1';
          2 : result:='2';
          3 : result:='3';
          4 : result:='4';
          5 : result:='5';
          6 : result:='6';
          7 : result:='7';
          8 : result:='8';
          9 : result:='9';
          0 : result:='0';
        end;
      end;
      

  6.   

    #1就是代表一个矩形框,你showmesage一下就知道,你要存的应该是长度为1的字符串
    用sonicer(极品瘦子猪哥靓) :
    ... := IntToStr(TerminalTypeComb1.ItemIndex+1)[1];
    这个就好了