adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select 姓名 as 姓名,max(case  when 课程='语文' then 分数 else 0 end)语文,max(case 课程 when '数学' then 分数 else 0 end)数学,max(case 课程 when '物理' then 分数 else 0 end)物理  into #tb1 from tb group by 姓名');
adoquery1.open;报错内容:
[error]unit1.pas[74]:illegal character in input file:'语'[$D3EF]
[error]unit1.pas[74]:illegal character in input file:'数'[$CAFD]
[error]unit1.pas[74]:illegal character in input file:'物'[$CEEF]
[Fatal error]project1.drp[5]:Could not compile used unit 'unit1.pas'

解决方案 »

  1.   


    adoquery1.Close;
    adoquery1.SQL.Clear;
    adoquery1.SQL.Add('select 姓名 as 姓名,max(case  when 课程=''语文'' then 分数 else 0 end) as 语文,max(case 课程 when ''数学'' then 分数 else 0 end) as 数学,max(case 课程 when ''物理'' then 分数 else 0 end) as 物理  into #tb1 from tb group by 姓名');
    adoquery1.open;试试
      

  2.   

    [error]unit1.pas[74]:illegal character in input file:'语'[$D3EF] 
    [error]unit1.pas[74]:illegal character in input file:'数'[$CAFD] 
    [error]unit1.pas[74]:illegal character in input file:'物'[$CEEF] 把' 改成''你执行adoquery1.open; 
    但sql里边Into #写临时表,会出错的...
      

  3.   

    adoquery1中查询临时表报无效,有办法解决吗
      

  4.   


    adoquery1.SQL.Add('select 姓名 as 姓名,max(case  when 课程=''语文'' then 分数 else 0 end) 语文,max(case 课程 when ''数学'' then 分数 else 0 end)数学,max(case 课程 when ''物理'' then 分数 else 0 end)物理  into #tb1 from tb group by 姓名'); 
      

  5.   

    最好把SQL语句给一个字符串 变量 ,adoquery1.SQL.Add(sSQL)
    这样好监控错在什么地方
      

  6.   

    SQL语句中用到单引号的地方,写在程序中要用两个单引号!