onexit da insert çalışıyor fakat editte hata veriyor ama kay

Delphi'de kod yazma ile ilgili sorularınızı bu foruma yazabilirsiniz.
Cevapla
Kullanıcı avatarı
delphist
Üye
Mesajlar: 595
Kayıt: 05 Oca 2005 04:34

onexit da insert çalışıyor fakat editte hata veriyor ama kay

Mesaj gönderen delphist »

S.a. Combox ın on exitinde table insert veya edit durumuna göre işlem yapıyorum. Fakat Hata olarak 'Satır güncelleştirme için bulamıyor' diyor fakat değiştirmeyi yapıyor ama exception düşüyor arkadaşlar...Lütfen yardımcı olursanız sevinirim.

Kod: Tümünü seç

procedure TFrm_kullgrupkayit.Edit1Exit(Sender: TObject);
var
editsakla:string;
kayitbul:string;
begin
if edit1.Text<>'' then
 begin
 dmuser.kayitbulq.Close;
 dmuser.kayitbulq.SQL.Clear;
 dmuser.kayitbulq.SQL.Add('SELECT * FROM TBLUSERGRUPKODU');
 dmuser.kayitbulq.SQL.Add('WHERE GRUP_KODU ='+QuotedStr(Edit1.Text)+'');
 dmuser.kayitbulq.Open;
 kayitbul:=Trim(dmuser.kayitbulq.fieldbyname('GRUP_KODU').AsString);
 if kayitbul<>'' then
  begin
  dmuser.TBLUSERGRUPKODU.Locate('GRUP_KODU',kayitbul,[]);
  dmuser.TBLUSERGRUPKODU.Edit;
  edit2.Text:=dmuser.TBLUSERGRUPKODUGRUP_ADI.AsString;
  ComboBox1.Text:=dmuser.TBLUSERGRUPKODUAKTIF_MI.Text;

  end
  else
  begin
  dmuser.TBLUSERGRUPKODU.Append;
  end;
 end
 else
 begin
 beep;
 edit1.SetFocus;
 end;



with(sender as Tedit)do
color:=clbtnface;
end;

Kod: Tümünü seç

procedure TFrm_kullgrupkayit.ComboBox1Exit(Sender: TObject);
begin
if dmuser.TBLUSERGRUPKODU.State = dsInsert then
 begin
 dmuser.TBLUSERGRUPKODUGRUP_KODU.AsString:=Edit1.Text;
 dmuser.TBLUSERGRUPKODUGRUP_ADI.AsString := edit2.Text;
 dmuser.TBLUSERGRUPKODUAKTIF_MI.AsString := ComboBox1.Text;
 dmuser.TBLUSERGRUPKODU.Post;
 edit1.Clear;
 edit2.Clear;
 ComboBox1.Clear;
 edit1.SetFocus;
 end;

if dmuser.TBLUSERGRUPKODU.State = dsEdit then
 begin
 dmuser.TBLUSERGRUPKODUGRUP_KODU.AsString := edit1.Text;
 dmuser.TBLUSERGRUPKODUGRUP_ADI.AsString := Edit2.Text;
 dmuser.TBLUSERGRUPKODUAKTIF_MI.AsString := ComboBox1.Text;
 dmuser.TBLUSERGRUPKODU.UpdateRecord;
 dmuser.TBLUSERGRUPKODU.Post;
 dmuser.TBLUSERGRUPKODU.Refresh;
 edit1.Clear;
 edit2.Clear;
 ComboBox1.Clear;
 edit1.SetFocus;
 end;
mkysoft
Kıdemli Üye
Mesajlar: 3110
Kayıt: 26 Ağu 2003 12:35
Konum: Berlin
İletişim:

Mesaj gönderen mkysoft »

nedeni combobox'ın az önce göstermiş olduğu kaydı sen update edip değiştirdiğin için olmasın? yukarıdaki editte kayıt eklediğin için aktif kayıt değişiyor bunun için hata veriyor sanırım.
Kullanıcı avatarı
delphist
Üye
Mesajlar: 595
Kayıt: 05 Oca 2005 04:34

Mesaj gönderen delphist »

hocam yanlız aware bileşenleri kullanmıyorum....problem başka ama çözemedim... :(
Cevapla