Konuyu Oyla:
  • Derecelendirme: 0/5 - 0 oy
  • 1
  • 2
  • 3
  • 4
  • 5
Adres hatası
#1
Merhaba.

Listview veya db den toplu kayıt silmek istediğimde adres hatası alıyorum fakat kayıtları 1 veya 2 kayıt sildiğimde hata almıyorum bu sorun neden kaynaklı olabilir.


procedure TForm2.BtnPLSilClick(Sender: TObject);
begin
  try
    With Form1.Query, Listv do
    begin
      if SelCount > 0 then
      begin
        for I := Items.Count - 1 downto 0 do
        begin
          if Items[I].Selected then
          begin
            Connection := Form1.Connection;
            Active := False;
            Close;
            SQL.Clear;
            SQL.Add('Delete From LISTLER Where ID=: DEL ' ) ;
            ParamByName('DEL').AsInteger := StrToInt(Items[I].SubItems[12] )  ; // Not: siteden kaynaklı icon nedeniyle aralarda boşluk bıraktım
            ExecSQL;
            Items.Delete(I);
          end;
        end;
      end;
    end;
  finally
    Form1.Query.Close;
  end;
end;





procedure TForm2.BtnPLSilClick(Sender: TObject);
begin
  try
    With  Listv do
    begin
      if SelCount > 0 then
      begin
        for I := Items.Count - 1 downto 0 do
        begin
          if Items[I].Selected then
          begin
            Items.Delete(I);
          end;
        end;
      end;
    end;
  finally
  end;
end;
Hayat bazen güzel olabiliyor.
Cevapla
#2
Selam,
Yapmanız gereken, önce listbox ı döngüye sokup SQL ile kayıtları silip, daha sonra listbox u temizlemenizdir. Listbox döngüde iken aradan item çıkartırsanız item count değiştiği için access violation hatası alırsınız.
WWW
Cevapla


Konu ile Alakalı Benzer Konular
Konular Yazar Yorumlar Okunma Son Yorum
  Runtime error 236 hatası yhackup 6 710 29-07-2026, Saat: 00:10
Son Yorum: emailx45
  matematiksel karşılaştırma hatası nevzatc 7 995 14-04-2026, Saat: 06:36
Son Yorum: emailx45
  Delphi ile SQL server bağlantı hatası yakalama Under 20 3.159 21-11-2025, Saat: 15:24
Son Yorum: mrmarman
  OpenSSL Hatası mcuyan 1 675 29-04-2025, Saat: 02:28
Son Yorum: mcuyan
Photo Delphi 12.2ilginç bir ide hatası tuna 13 4.126 25-03-2025, Saat: 09:47
Son Yorum: tuna



Konuyu Okuyanlar: 1 Ziyaretçi