ODBCDatabase.PrimaryKeys

From Xojo Documentation

Method

ODBCDatabase.PrimaryKeys(TableName as String) As RowSet

Supported for all project types and targets.

Returns a RowSet containing the column names that make up the primary key for a table.

References

SQLPrimaryKeys ODBC function

Example

Displays the primary keys for a table:

Var db As New ODBCDatabase

db.DataSource = "TeamExample"

Try
db.Connect
Var rs As RowSet
rs = db.PrimaryKeys("Team")
If rs <> Nil Then
While Not rs.AfterLastRow
ListBox1.AddRow(rs.ColumnAt(1).StringValue)
rs.MoveToNextRow
Wend
rs.Close
End If
Catch error As DatabaseException
MessageBox("Error: " + error.Message)
End Try