var str:string;
begin
str:='update cy set 语文=10,数学=10,英语=10,自然科学=90,思政=44 where xsbh= "C03010101"
      update cy set 语文=50,数学=80,英语=77,自然科学=88,思政=77 where xsbh= "C03010102"
      update cy set 语文=60,数学=80,英语=60,自然科学=55,思政=88 where xsbh= "C03010103"
      update cy set 语文=70,数学=70,英语=66,自然科学=66,思政=87 where xsbh= "C03010104"
      update cy set 语文=70,数学=70,英语=99,自然科学=66,思政=76 where xsbh= "C03010105"
      update cy set 语文=80,数学=60,英语=99,自然科学=55,思政=75 where xsbh= "C03010106"';
adoquery1.close;
adoquery1.sql.clear;
adoquery1.sql.add(str);
adoquery1.execsql;
以上程序不能编译通不过;原因在于那个赋值语句,我想请问像这样几个语句如何用一个adoquery1.sql.add()来表达。其实上我面那个赋值语句还有很多,一个班一般的有60个人了

解决方案 »

  1.   

    str:='update cy set 语文=10,数学=10,英语=10,自然科学=90,思政=44 where xsbh= ‘C03010101’’+
          ‘update cy set 语文=50,数学=80,英语=77,自然科学=88,思政=77 where xsbh= ‘C03010102’’+
          ‘update cy set 语文=60,数学=80,英语=60,自然科学=55,思政=88 where xsbh= ‘C03010103’’+
          ‘update cy set 语文=70,数学=70,英语=66,自然科学=66,思政=87 where xsbh= ‘C03010104’’+
          ‘update cy set 语文=70,数学=70,英语=99,自然科学=66,思政=76 where xsbh= ‘C03010105’’+
          ‘update cy set 语文=80,数学=60,英语=99,自然科学=55,思政=75 where xsbh= ‘C03010106’’;
      

  2.   

    把update改为这样就可以了。。
    str:='update cy set 语文=10,数学=10,英语=10,自然科学=90,思 =44 wheresbh= '
    + '''C03010101'''; 
      

  3.   

    两条SQL语句之间最好用#13+#10分隔 如
    str:='update cy set 语文=10,数学=10,英语=10,自然科学=90,思政=44 where xsbh= ''C03010101'''+#13+#10+
          'update cy set 语文=50,数学=80,英语=77,自然科学=88,思政=77 where xsbh= 'C03010102'''+
      

  4.   

    cyblueboy83(随风飞翔) 
    当str为一句update时是可以的,但是当str有两句update时又不行了,我的意思是当超过两句话时怎么表达
    即:
    var str:string;
    begin
    str:='update cy set 语文=10,数学=10,英语=10,自然科学=90 where xsbh= "C03010101"
          update cy set 语文=50,数学=80,英语=77,自然科学=88 where xsbh= "C03010102"
          update cy set 语文=60,数学=80,英语=60,自然科学=55 where xsbh= "C03010103"
          update cy set 语文=70,数学=70,英语=66,自然科学=66 where xsbh= "C03010104"
          update cy set 语文=70,数学=70,英语=99,自然科学=66 where xsbh= "C03010105"
          update cy set 语文=80,数学=60,英语=99,自然科学=55 where xsbh= "C03010106"';
    adoquery1.close;
    adoquery1.sql.clear;
    adoquery1.sql.add(str);
    adoquery1.execsql;
    这个程序如何表达?
      

  5.   

    str:='update cy set 语文=10,数学=10,英语=10,自然科学=90,思政=44 where xsbh= ''C03010101'''+#10+#13+
          'update cy set 语文=50,数学=80,英语=77,自然科学=88,思政=77 where xsbh= ''C03010102'''+#10+#13+
          'update cy set 语文=60,数学=80,英语=60,自然科学=55,思政=88 where xsbh= ''C03010103'''+#10+#13+
          'update cy set 语文=70,数学=70,英语=66,自然科学=66,思政=87 where xsbh= ''C03010104'''+#10+#13+
          'update cy set 语文=70,数学=70,英语=99,自然科学=66,思政=76 where xsbh= ''C03010105'''+#10+#13+
          'update cy set 语文=80,数学=60,英语=99,自然科学=55,思政=75 where xsbh= ''C03010106''';
    SQL 语句如上
      

  6.   

    老大,还是不行呀!
    错误提示如下图:http://wyzx.hyedu.net/2004/2003/newsimg/error.jpg
      

  7.   

    我晕倒。两句也可以呀!就是加个‘+’号呀。。
    str:='update cy set 语文=10,数学=10,英语=10,自然科学=90,思 =44 wheresbh= '
    + '''C03010101''' +
    ' update cy set 语文=10,数学=10,英语=10,自然科学=90,思 =44 wheresbh= '
    + '''C03010102''';
      

  8.   

    用sql.add('update cy set 语文=10,数学=10,英语=10,自然科学=90,思政=44 where xsbh= "C03010101" ');
    sql.add('update cy set 语文=10,数学=10,英语=10,自然科学=90,思政=44 where xsbh= "C03010102" ');
    ........一条条的加没问题,测试通过。
      

  9.   

    因为你用的变量str是string类型的,它有长度限制255,超出部份将被省略
    所以还是一条条的加为好,在每个语句update语句结束时加一个分号';'
    如下:sql.add('update cy set 语文=10,数学=10,英语=10,自然科学=90,思政=44 where xsbh='''C03010101'''; ');
    sql.add('update cy set 语文=10,数学=10,英语=10,自然科学=90,思政=44 where xsbh='''C03010102'''; ');
    ........
      

  10.   

    我也想过这样做,但是不是效率低了点!!
    我为何在做这个东西呢?
    因为我在做一个成绩管理系统,它有服务器端和客户端,
    在服务器端有所有学生的名单,在客户端下载了一个班
    级的名单,我目前的问题是将录好成绩的名单传上去,
    我是通过在客户端生成一组sql语句,然后上传到服务器
    端,再执行它,将之替换,起到成绩上传的功能。我生成
    的一组sql语句如下(成绩还没有完全录入)
    update cy set 语文=10,数学=10,英语=10,自然科学=0,思政=0 where xsbh= "C03010101"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010102"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010103"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010104"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010105"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010106"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010107"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010108"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010109"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010110"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010111"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010112"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010113"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010114"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010115"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010116"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010117"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010118"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010119"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010120"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010121"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010122"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010123"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010124"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010125"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010126"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010127"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010128"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010129"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010130"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010131"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010132"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010133"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010134"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010135"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010136"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010137"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010138"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010139"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010140"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010141"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010142"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010143"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010144"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010145"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010146"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010147"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010148"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010149"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010150"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010151"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010152"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010153"
    update cy set 语文=0,数学=0,英语=0,自然科学=0,思政=0 where xsbh= "C03010154"
      

  11.   

    你在你的数据库里面写一个存储过程,里面有几个参数,然后你的你的delphi里面调用这个存储过程
    这样,你可以大批量更新数据的!!
      

  12.   

    我是用access2000的怎么用存储过程呀?
      

  13.   

    如果能用存储过程
    MIRCOSOFT肯定会请去做资深顾问了
      

  14.   

    呵呵
    TO:楼主
    你这种方式简直有点荒谬
    语法是没问题
    但是你想过没有
    STRING类型或者SQL语句是否支持你所写的字符的最大长度。
      

  15.   

    你就不能够一条一条的执行么?你的方法有点问题,因为是在access里面。如果是sql server应该有办法可以实现
      

  16.   

    说等与白说
    楼主:为什么不换一种角度考虑呢?
    客户端生成XML文件
    再从XML文件导入要方便的多
    而且代码很简单
    速度也没问题的
    如果你一意孤行的话,我也没办法
    PS:有问题,不要老想着别人去帮你,有时间可以自己多考虑一下
    不过在这有问题,大家还是比较爱帮忙解决的。