Ludziska napisalem sobie w delphi prosty programik tworzy mi sie baza danych i tabela taryfy
wpisuje to do comboboxa i wyglada to tak:
id ... ...
1 ... ...
2 ... ...
3 ... ...
I teraz obsluga w delphi:
procedure TUT.btnDeleteClick(Sender: TObject);
var
text: string;
begin
text:='DELETE FROM `taryfy` WHERE `taryfy`.`id` =' + ComboBox1.Text;
DM.ZQuery1.Close;
DM.ZQuery1.SQL.Text:= text;
Dm.ZQuery1.ExecSQL;
text:='';
text:='update taryfy set id = id-1 where id >' + ComboBox1.Text;
DM.ZQuery1.Close;
DM.ZQuery1.SQL.Text:=text;
DM.ZQuery1.ExecSQL;
FormActivate(Self);
end;
procedure TUT.FormActivate(Sender: TObject);
begin
ComboBox1.Items.Clear;
DM.ZConnection1.Database:='delphitest';
DM.ZConnection1.Connect;
DM.ZQuery1.SQL.Text:= 'SELECT * FROM taryfy;';
DM.ZQuery1.Open;
DM.ZQuery1.First;
while not DM.ZQuery1.Eof do
begin
ComboBox1.Items.Add(DM.ZQuery1.FieldByName('id').AsString);
DM.ZQuery1.Next;
end
end;
wszystko ladnie pieknie jak usune np 2 to mam:
id ... ...
1 ... ...
2 ... ...
Tyle ze jak dodam nowy rekord to wskakuje nr 4 jak zrobic zeby byla 3 ?? ID jest auto_increment