listbox1里面的内容为:
A
B
C
有一张table1表为:
Dj      DateTemp     Kw        Xq
001     2004-04-05            星期一
001     2004-04-06            星期二
001     2004-04-07            星期三
001     2004-04-08            星期四
001     2004-04-09            星期五
001     2004-04-10            星期六
001     2004-04-11            星期天
001     2004-04-12            星期一
.....................................如何做一个循环把listbox的各项插入到table1表中的Kw字段呢?但是天数是星期六和星期天就不用插入数据就好象是变换到现在这样的表...依次循环下去。
Dj      DateTemp     Kw        Xq
001     2004-04-05    A       星期一
001     2004-04-06    B       星期二
001     2004-04-07    C       星期三
001     2004-04-08    A       星期四
001     2004-04-09    B       星期五
001     2004-04-10            星期六
001     2004-04-11            星期天
001     2004-04-12    C       星期一
001     2004-04-13    A       星期二
001     2004-04-14    B       星期三

解决方案 »

  1.   

    假如用Ado连接:Adoq
    var
      index: integer;
      strXq: string;
      nMax: integer;
    index := 0;
    nMax := listbox1.Items.Count-1;if nMax=0 then exit;
    while not adoq.eof do begin
      strXq := adoq.FieldByName.AsString;  
      if (strXq<>'星期六') and (strXq<>'星期天') then do begin
        adoq.Edit;
        adoq.FieldByName('Kw').Value := listbox1.Items.Strings[index];
        adoq.Post;
        inc(index);
        if index>=nMax then index := 0;
      end;end;
      

  2.   

    strXq := adoq.FieldByName('Xq').AsString;
      

  3.   

    漏掉了非常重要的next;var
      index: integer;
      strXq: string;
      nMax: integer;begin
    index := 0;
    nMax := listbox1.Items.Count-1;if nMax=0 then exit;
    while not adoq.eof do begin
      strXq := adoq.FieldByName('Xq').AsString;  
      if (strXq<>'星期六') and (strXq<>'星期天') then do begin
        adoq.Edit;
        adoq.FieldByName('Kw').Value := listbox1.Items.Strings[index];
        adoq.Post;
        inc(index);
        if index>=nMax then index := 0;
      end;
      next;
    end;
    end;