ODBCDatabase.PrimaryKeys

From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!
Method

ODBCDatabase.PrimaryKeys(TableName as String) As RecordSet

Supported for all project types and targets.

Returns a RecordSet 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"

If Not db.Connect Then
MsgBox("Error: " + db.ErrorMessage)
End If

Var rs As RecordSet
rs = db.PrimaryKeys("Team")

If rs <> Nil Then
While Not rs.EOF
ListBox1.AddRow(rs.IdxField(1).StringValue)
rs.MoveNext
Wend
rs.Close
End If