Hi anyone here knows how to get row header in sql table? I tried the following one but it prompts an OutOfBoundsException
row.ColumnAt(-1).StringValue
Hi anyone here knows how to get row header in sql table? I tried the following one but it prompts an OutOfBoundsException
row.ColumnAt(-1).StringValue
Do you want the Coumn names (as set in the TABLE declaration) ?
What is the used SQL (SQLite, Post , MySQL, etc.) ?
@rhea g What exactly do you expect to be a row header? Do you mean the row ID?
Do you want to show the content of a sql table into a listbox?
In this case, fill in the initial value for your list box in the XOJO editor or you add into the open event of the listbox something like
me.HeaderAt(0) = "header name of column one"
me.HeaderAt(1) = "header name of column two"
[quote=473735:@rhea g]Hi anyone here knows how to get row header in sql table? I tried the following one but it prompts an OutOfBoundsException
row.ColumnAt(-1).StringValue
Why do you imagine there is a row header? An SQL table in a database is not a CSV file.
This is not mandatory: some reserve the very first record as a header containing a list of field names
; from:
Comma-separated_values .
Emile… that may be true for a CSV file, but never for a properly designed DATABASE field (as specified in the OP)
OP
[quote=473735:@rhea g]Hi anyone here knows how to get row header in sql table? I tried the following one but it prompts an OutOfBoundsException
row.ColumnAt(-1).StringValue
Hi
Use :-
SELECT COLUMN_NAME,* FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = ‘YourTableName’ AND TABLE_SCHEMA='YourSchemaName
[quote=473937:@Rod Pascoe]SELECT COLUMN_NAME,* FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = ‘YourTableName’ AND TABLE_SCHEMA='YourSchemaName[/quote]
That might return the Table Schema for a particular database engine…but is not the correct syntax for all (especially not for SQLite).
Perhaps the use of DB.FieldSchema(tablename) might be what you were attempting to describe. (Note: this may have changed in API2.0) and may or may not work for all database engines (but it DOES for Sqlite )
But we are just guessing as to what the OP was actually referring to. Since they have not commented on any of the above responses.
I wonder if the OP is just looking for Databasecolumn.name .
The OP is new to Xojo (2 posts on 3 weeks), and do not explained its concern.
Which leaves the rest of us still guessing
Yes.