用vsflexgrid绑定数据库后,显示出来的数据都是10进制的,我想使某一列的数据显示为16进制,我试了很多次都没有成功。高手们帮帮忙。

解决方案 »

  1.   

    SQL Server 有这样的函数?
      
      

  2.   

    SQL> select to_char(45,'xxxx') from dual;TO_CHAR(45,'XXXX')
    -------------------
        2d
      

  3.   

    如果需要转化换的数字比较长 xxxx四位转不了 就多+几个x
    SQL> select to_char(45,'xxxxxxxxxxxxx') from dual;否则,x位数不够的话:
    SQL> select to_char(45,'x') from dual;TO_CHAR(45,'X')
    ---------------
    ##SQL> select to_char(45,'xx') from dual;TO_CHAR(45,'XX')
    ----------------
     2d
      

  4.   

    --昨天答的不完善,完成你的问题
    --   http://support.microsoft.com/kb/104829/zh-cn
    drop proc sp_hexadecimal   create procedure sp_hexadecimal
         @binvalue varbinary(255)
       as
       declare @charvalue varchar(255)
       declare @i int
       declare @length int
       declare @hexstring char(16)   select @charvalue = '0x'
       select @i = 1
       select @length = datalength(@binvalue)
       SET @hexstring = '0123456789abcdef'   while (@i <= @length)
       begin     declare @tempint int
         declare @firstint int
         declare @secondint int     select @tempint = convert(int, substring(@binvalue,@i,1))
         select @firstint = floor(@tempint/16)
         select @secondint = @tempint - (@firstint*16)     select @charvalue = @charvalue +
           substring(@hexstring, @firstint+1, 1) +
           substring(@hexstring, @secondint+1, 1)     select @i = @i + 1   end   select 'sp_hexadecimal'=@charvalue

    /*调用
         declare @bin varbinary(255)
         select @bin =cast(99 as binary(3)) -- @@dbts
         execute sp_hexadecimal @bin
         select 'isql' = @bin
         
    */