大家好:
   我有三个问题,请一一回答,谢谢(每个问题分):
   1。“sql.add('update xscj.课程表 set xh='''+'00001111'+''' where xh is null'”这句话放到程序中执行时不做处理?为什么? "xh is null"不对吗?可是放到sql server的企业管理器中则可以执行?
   
   2。 我要将表中大记录按照次序一条一条的进行修改其中xh的内容,第一条为00001,一次类推,我的写法为什么出现错误提示,"修改第二条时提示表close":
   var 
    i,j,k:integer;
   begin
     k:=1;
     with adoQuery1 do
       begin
         ........//查找记录
       
       j:=recordcounts;
       end;  
      
      first
      for i:=0 to j-1 do
          
          begin 
           k:=K+1 
           with adoQuery2 do
            begin
         ........update...//逐个修改序号
            end; 
  3.当表中的数据量很大时,无论在企业管理器中还是在程序中:
       select * from 学生情况表 where xm='ll' 都会提示数据超时
我也建立了索引,请问如何解决?     请各位大侠认真回答,若分不够可以提出来,我再加。请不要敷衍,谢谢!

解决方案 »

  1.   

    1。“sql.add('update xscj.课程表 set xh='00001111' where xh is null'”试试?
      

  2.   

    2       first
          for i:=0 to j-1 do
              
              begin 
               k:=K+1 
               with adoQuery2 do
                begin
             ........update...//逐个修改序号
                end; 
    其中为什么用 adoQuery2 ? 改成 adoQuery1 试试?
      

  3.   

    看来这分不好挣.  
    之前, 我先给你点建议:
      1. 表名和字段名不要用中文,  这在有的情况下会由于数据库语系的问题不被承让.
      2. 表名和字段名最好用英文取, 这样好理解.
      3.    for i:=0 to j-1 do 最好改成 while not adoQuery1.Eof do ...
      4.  看上去你这表里面没有一个唯一识别的关键字(主索引)
    好, 这开始回答你的问题好了.
      1. where xh is null  不行的话, 你可以试 where xh='';
      2.我不知道打开adoquery1 的目的是做什么, 只是为了取记录数吗? 那adoquery是专门改数据了的吧. 建议改成
        adoquery1.add('select * from xscj.课程表 where ....');
        ...
       
       while not adoquery1.eof do
        begin
           adoquery1.Edit;
           adoquery1.FieldByName('xh').AsString := .... ;
           adoquery1.Post;
           adoquery1.Next;
        end;
              
      

  4.   

    "xh=''"不行,因为我试了。因为不是‘’,而是null
      

  5.   

    "xh is null" 没有问题.
      

  6.   

    第一个问题没问题:
      with ADOQuery1 do
      begin
        Close;
        sql.add('update 课程表 set xh='''+'00001111'+''' where xh is null');
        ExecSQL;
      end;
    请仔细看你自己的代码是否有问题
    第二个问题说得很不明确,最好将问题描述清楚点!
      

  7.   

    xh is null有问题的话就要len来代替
    1。“sql.add('update xscj.课程表 set xh='''+'00001111'+''' where len(xh)=0'”
    2   var 
        i,j,k:integer;
       begin
         k:=1;       
          adoquery2.first;
          for i:=0 to adoquery2.recordcount-1 do          
              begin 
                adoquery2.edit;
                adoquery2.fieldbyname('xh').asstring:=更新的值;
                adoquery2.post;
                adoquery2.next;
                k:=K+1;
              end; 
      end;
    3.关注中。
      

  8.   

    1. where xh is null  不行的话, 你可以试 where xh='';
      2.我不知道打开adoquery1 的目的是做什么, 只是为了取记录数吗? 那adoquery是专门改数据了的吧. 建议改成
        adoquery1.add('select * from xscj.课程表 where ....');
        ...
       
       while not adoquery1.eof do
        begin
           adoquery1.Edit;
           adoquery1.FieldByName('xh').AsString := .... ;
           adoquery1.Post;
           adoquery1.Next;
        end;
              
    3.选中Microsoft SQL Servers-->工具栏,工具-->选项-->高级-->查询超时-->改为0
    选中Microsoft SQL Servers-->工具栏,工具-->选项-->高级-->连接超时-->改为0
    ADOConnectionTimeout=0;