tabloda veri yokken a=0 koşulunu sağlayıp ekliyor daha sonra a>=1 koşulunu da sağladığı için bu koşulun kodlarını da çalıştırıyor.
hocam ne yapmalıyım amacım dediğim gibi tabloda hiç veri yoksa eklesin 1 ve ya daha fazla veri varsa eklemesin?
button click kodlarım burada
Kod: Tümünü seç
var
a,i:integer;
sayi:char;
begin
q.Close;
q.SQL.Clear;
q.SQL.Add('select isim from lol');
q.ExecSQL;
a:=q.RecordCount;
if a=0 then
begin
q.close;
q.SQL.Clear;
q.SQL.Add('INSERT INTO lol (isim) VALUES ("'+edit2.Text+'")');
q.ExecSQL;
q2.close;
q2.SQL.Clear;
q2.SQL.Add('INSERT INTO mac (nick) VALUES ("'+edit2.Text+'")');
q2.ExecSQL;
timer1.Enabled:=true;
end;
if a >= 1 then
q.Close;
q.SQL.Clear;
q.SQL.Add('select isim from lol limit 1') ;
q.open;
edit1.Text:=q.Fields[0].AsString;
q.Close;
q.SQL.Clear;
q.SQL.Add('UPDATE mac set mac= 1 where nick="'+edit1.Text+'"');
q.ExecSQL;
end;