Topic: ROWID in a TableGrid - SOLVED
Hi!
How could I show de row id in a tablegrid load from a database with principal.TableGrid.dbSQL ???
principal.TableGrid.sbSQL := 'SELECT rowid, name, phone FROM database'; >>>>> doesn't work
Thanks !!!
My Visual Database → SQL queries → ROWID in a TableGrid - SOLVED
Hi!
How could I show de row id in a tablegrid load from a database with principal.TableGrid.dbSQL ???
principal.TableGrid.sbSQL := 'SELECT rowid, name, phone FROM database'; >>>>> doesn't work
Thanks !!!
principal.TableGrid.sbSQL := 'SELECT id, name, phone FROM database'; //should do the trick
principal.TableGrid.sbSQL := 'SELECT id, name, phone FROM database'; //should do the trick
Thanks but id shows the id of the record. if I deleted records before use the statemen the number shown is not correlative , and I'm looking for a autoincrement column only shown in the tablegrid.
Hello meideprac-x,
If your are talking about rowid as in "unique number referencing a record in a database", if you delete records, numbering is not continuous anymore, there is nothing you can do without a lot of coding to change that.
But if you are talking about rowid as in "number of the row in the tablegrid", even if you have deleted records, there is a way to display a column in your tablegrid with continuous numbering.
In the set-up of your tablegrid (or search button) just had the "# (Auto Increment)" found at the very bottom of the field selection window and you'll get a colum displaying a continuous numbering. If you put it side by side with the "record id" and you have deleted some records, you'll see the difference.
Hope this helps.
Cheers
Mathias
But if you are talking about rowid as in "number of the row in the tablegrid", even if you have deleted records, there is a way to display a column in your tablegrid with continuous numbering.
In the set-up of your tablegrid (or search button) just had the "# (Auto Increment)" found at the very bottom of the field selection window and you'll get a colum displaying a continuous numbering. If you put it side by side with the "record id" and you have deleted some records, you'll see the difference.
Hope this helps.
Cheers
Mathias
Hi Mathias! Thanks. That's I want to do, but with a script. Could you help me please?
meideprac-x
Can you more explain, what exactly you want to do?
meideprac-x
Can you more explain, what exactly you want to do?
Hi Dimitry!
I have a table with an ID column that has no correlative number (because I deleted rows above) and I want to present it in a tableGrid whose field ID must have correlative number. That is so easy with the Object Inspector > properties > settings > select #Auto Increment like explain Mathias, but I use this tablegrid to display different data according to different search criteria I and dump the data using script (principal.TableGrid.sbSQL := 'SELECT id, name, phone FROM database'), without using the Object Inspector.
How could I add a column in this tablegrid wich was Auto Increase within script?
I hope I explained well, excuse my bad English
Thanks!
Javi
meideprac-x
Check out this example:
procedure Form1_bScript_OnClick (Sender: string; var Cancel: boolean);
begin
Form1.GridEmployees.dbSQL:='SELECT id, "$autoinc", lastname, firstname, salary FROM employees'; // the id field, want to be able to edit or delete the entry from the table component
Form1.GridEmployees.dbGeneralTable := 'employees'; // Optional (in the case of complex SQL queries with sub queries, you need to choose the main table of the database, also it need to be able to edit or delete the entry from the table component)
Form1.GridEmployees.dbListFieldsNames :='delete_col,#,name2,name3,name4'; // If you do not want to see the value of the id in the component table, enter a name for the column delete_col
Form1.GridEmployees.dbSQLExecute;
end;
meideprac-x
Check out this example:procedure Form1_bScript_OnClick (Sender: string; var Cancel: boolean); begin Form1.GridEmployees.dbSQL:='SELECT id, "$autoinc", lastname, firstname, salary FROM employees'; // the id field, want to be able to edit or delete the entry from the table component Form1.GridEmployees.dbGeneralTable := 'employees'; // Optional (in the case of complex SQL queries with sub queries, you need to choose the main table of the database, also it need to be able to edit or delete the entry from the table component) Form1.GridEmployees.dbListFieldsNames :='delete_col,#,name2,name3,name4'; // If you do not want to see the value of the id in the component table, enter a name for the column delete_col Form1.GridEmployees.dbSQLExecute; end;
Thanks Dimitry, "$autoinc" is the solution. It's what I was looking for
My Visual Database → SQL queries → ROWID in a TableGrid - SOLVED
Powered by PunBB, supported by Informer Technologies, Inc.
Theme Hydrogen by Kushi