Topic: Нумерация строк TableGrib с помощью SQL

Доброго времени суток!
При попытке пронумеровать строки TableGrid при помощи SQL запроса, получаю пустой столбец. Подскажите, что не так?
Заранее огромное спасибо!

Post's attachments

Attachment icon AutoNum.rar 293.34 kb, 235 downloads since 2020-11-11 

I'm just learning

Re: Нумерация строк TableGrib с помощью SQL

Hello Ronin751

И удалив эту строку :

Form1.TableGrid1.Columns[0].Visible:=False;

Translated with Google

JB

Re: Нумерация строк TableGrib с помощью SQL

Здравствуйте jean.brezhonek!
Спасибо, что уделили внимание этой теме.
Дело в том, что если удалить строку

Form1.TableGrid1.Columns[0].Visible:=False

, в TableGrid полу № все равно остается пустым.
Мне же нужно, чтоб в поле № ( $autoinc AS № ) отображались порядковые номера строк TableGrid.

Hello jean.brezhonek!
Thank you for your attention to this topic.
The fact is that if you delete the line

Form1.TableGrid1.Columns [0] .Visible: = False

, in the TableGrid floor №. still remains empty.
I also need that in the field №. ($ autoinc AS №.) the ordinal numbers of the TableGrid rows are displayed.

Translated with Google

I'm just learning

Re: Нумерация строк TableGrib с помощью SQL

Если изменить запрос на:

procedure Form1_Button2_OnClick (Sender: TObject; var Cancel: boolean);
begin
    Form1.TableGrid1.dbSQL:='SELECT id, "$autoinc", name AS name FROM NAMES ORDER BY name';
    Form1.TableGrid1.dbSQLExecute;
    Form1.TableGrid1.Columns[0].Visible:=False;
    Form1.TableGrid1.Columns[1].Header.Caption:='№';
end;

тогда всё срабатывает хорошо. Но только до того момента, пока не добавляются или не удаляются данные.
Почему то после этого столбец id и стает не скрывается, а столбец меняет свое название на $autoinc.
Что с этим можно сделать?
.
.

If you change the request to:

procedure Form1_Button2_OnClick (Sender: TObject; var Cancel: boolean);
begin
    Form1.TableGrid1.dbSQL:='SELECT id, "$autoinc", name AS name FROM NAMES ORDER BY name';
    Form1.TableGrid1.dbSQLExecute;
    Form1.TableGrid1.Columns[0].Visible:=False;
    Form1.TableGrid1.Columns[1].Header.Caption:='№';
end;

then everything works fine. But only until the moment when data is added or removed.
For some reason, after that, the id column is not hidden, and the column No. changes its name to $autoinc.
What can you do about it?
.
Translated with Google

I'm just learning