Q&A

  • 트리뷰 관련... 코드좀 봐주세요...
디비에 있는 자료를 트리뷰로 보이기 위한 코드입니다...

근데 second code부분의 코드를 삽입하니 에러가 나요...

좀 가르쳐 주세요...



with qry_tree1 do begin

Close;

Sql.Clear;

Sql.Add(' select distinct Cd_first_name from code_manage');

open;

if recordcount > 0 then begin

first;

Treeview.Items.Clear;

While not EOF do begin

first_cd := FieldByName('Cd_first_name').AsString;

parent1 := Treeview.Items.Add(nil, first_cd);



////////////////////// second code start /////////////////////////////

with qry_tree2 do begin

Close;

Sql.Clear;

Sql.Add(' select distinct Cd_second_name from code_manage');

Sql.Add(' where Cd_first_name = '''+first_cd+''' ');

open;

if recordcount > 0 then begin

first;

Treeview.Items.Clear;

While not EOF do begin

second_cd := FieldByName('Cd_second_name').AsString;

child1 := Treeview.Items.AddChild(parent1, second_cd);

////////////////////////////////////////////////////////////////////////



////////////////////////////////////////////////////////////////////////

next;

end;

end;

end;

///////////////////// second code end ///////////////////////////////



next;

end;

end;

end;

1  COMMENTS
  • Profile
    장순석 2001.06.13 03:48
    초보맨 wrote:

    > 디비에 있는 자료를 트리뷰로 보이기 위한 코드입니다...

    > 근데 second code부분의 코드를 삽입하니 에러가 나요...

    > 좀 가르쳐 주세요...

    >

    > with qry_tree1 do begin

    > Close;

    > Sql.Clear;

    > Sql.Add(' select distinct Cd_first_name from code_manage');

    > open;

    > if recordcount > 0 then begin

    > first;

    > Treeview.Items.Clear;

    > While not EOF do begin

    > first_cd := FieldByName('Cd_first_name').AsString;

    > parent1 := Treeview.Items.Add(nil, first_cd);

    >

    > ////////////////////// second code start /////////////////////////////

    > with qry_tree2 do begin

    > Close;

    > Sql.Clear;

    > Sql.Add(' select distinct Cd_second_name from code_manage');

    > Sql.Add(' where Cd_first_name = '''+first_cd+''' ');

    > open;

    > if recordcount > 0 then begin

    > first;

    > Treeview.Items.Clear;

    > While not EOF do begin

    > second_cd := FieldByName('Cd_second_name').AsString;

    > child1 := Treeview.Items.AddChild(parent1, second_cd);

    > ////////////////////////////////////////////////////////////////////////

    >

    > ////////////////////////////////////////////////////////////////////////

    > next;

    > end;

    > end;

    > end;

    > ///////////////////// second code end ///////////////////////////////

    >

    > next;

    > end;

    > end;

    > end;



    Child Item의 First 다음에 Treeview.Items.Clear; 가 있어서 TreeView를 계속 Clear

    시키고 있군요.