Topic: Sort in Combobox
Hi,
Before updating from SQLITE do MYSQL i cann sorting in Combobox with change the ID of the object and then autosort in combobox.
Script wat i use :
procedure FORM1_BtDown_OnClick (Sender: string; var Cancel: boolean);
begin
if(FORM1.TABLEGRID.SelectedRow<FORM1.TABLEGRID.RowCount-1)then
begin
SQLExecute('UPDATE DB SET id="'+inttostr(500)+'" WHERE id = "'+inttostr(FORM1.TABLEGRID.SelectedRow+1)+'"');
SQLExecute('UPDATE DB SET id="'+inttostr(FORM1.TABLEGRID.SelectedRow+1)+'" WHERE id = "'+inttostr(FORM1.TABLEGRID.SelectedRow)+'"');
SQLExecute('UPDATE DB SET id="'+inttostr(FORM1.TABLEGRID.SelectedRow)+'" WHERE id = "'+inttostr(500)+'"');
FORM1.TABLEGRID.SelectedRow := FORM1.TABLEGRID.SelectedRow+1;
FORM1.TABLEGRID.dbUpdate;
end
end;
The problem in MYSQL is that ID start at number 1 but in mysql the ID start at number 0.
Becouse this my script not working in MYSQL.
I can create some standing column in databaze and change stih value +1 or -1 but after this a cannt change sorting combobox by another column. Just by ID.
I try this to but without good output.
procedure Form1_ComboBox1_OnMouseEnter (Sender: string);
var
m,i : integer;
begin
m := sqlexecute ('select max(DB_standing) from DB');
i:=0;
while(i<=m)do
begin
Form1.ComboBox1.Items.add(sqlexecute('select DB_standing from DB where DB_standing = "'+inttostr(i)+'"'));
i:=i+1;
end;
removedupli(Form1.ComboBox1); // procedure from me
end;
Cann please somebody help ???