Public Function GetPrimaryKey( _
ByVal connectionString As String, _
ByVal tableName As String, _
ByVal schema As String) As String() _
Implements Microsoft.Web.Management.DatabaseManager.IDbTableManager.GetPrimaryKey
Dim restrictions() As String = New String() {Nothing, Nothing, tableName}
Dim dataTable As DataTable
Dim primaryKeys As List(Of String) = New List(Of String)
' Create a connection to the database.
Dim connection As OleDbConnection = New OleDbConnection(connectionString)
connection.Open()
' Open the schema information for the primary keys.
dataTable = connection.GetOleDbSchemaTable(OleDbSchemaGuid.Primary_Keys, restrictions)
' Enumerate the table's primary keys.
For Each row As DataRow In dataTable.Rows
' Append each primary key to the list.
primaryKeys.Add(row("COLUMN_NAME").ToString)
Next
' Return the list of primary keys.
Return primaryKeys.ToArray
End Function