Microsoft Business Connectivity Services (BCS) 可從以下各類資料庫連接到外部資料:
Microsoft SQL Server
Oracle
OLE DB
ODBC
如何:基於 SQL Server 表建立外部內容類型這一主題說明使用 Business Connectivity Services 顯示來自 SQL Server 資料庫的外部資料的基本方式。在使用其他資料庫(如 Oracle、OLE DB 和 ODBC)時,必須遵循下列方法之一(因為 Microsoft SharePoint Designer 2010 不支援這些資料庫):
從頭開始建立 Business Connectivity Services 模型。有關資訊,請參閱創作 BDC 模型。有關編寫或修改 Oracle 資料庫的模型時的注意事項,請參閱下一節。
建立 Web 服務或 .NET 串連程式集,為資料庫中公開的外部資料提供介面。有關詳細資料,請參閱Creating Web and WCF Services for Business Connectivity Services和如何:建立 .NET 串連程式集。
建立 BDC 模型以串連到 Oracle 資料庫
按照創作 BDC 模型中的過程執行操作以從頭開始建立模型。
在編寫或修改 BDC 模型以串連到 Oracle 時,應記住以下注意事項:
Oracle SQL 文法要求您按以下方式指定查詢中的參數:為參數添加冒號 (:) 而非 @ 符號首碼。確保在中繼資料的 SQL 陳述式中正確設定它們。
如果 Oracle 串連需要連接字串中的顯式使用者識別碼 和密碼參數,則:
使用 Oracle 憑據在 Secure Store Service 中設定應用程式定義。
使用 RdbCredentials 的 AuthenticationMode。
在將 RdbCredentials 用作驗證模式時,無法使用 RdbConnection User ID 和 RdbConnection Password 屬性,因為這些值是由 Secure Store Service 提供的。如果指定這些值,則會將其忽略。必須使用安全儲存來提供 Oracle 憑據。
必須在伺服器陣列中的所有電腦上安裝 Oracle 用戶端,並且必須將 TNS net 服務配置為從 SharePoint 串連到 Oracle。這對於伺服器上的外部清單、Web 組件和設定檔頁面是必需的。由於應用程式(如搜尋)只在應用程式伺服器上運行,因此可以在應用程式伺服器上安裝 Oracle 用戶端。搜尋將只從應用程式伺服器串連。簡而言之,必須在從中串連到 Oracle 的伺服器陣列的電腦上安裝 Oracle 用戶端。出於同一原因,還必須在富用戶端電腦上安裝 Oracle 用戶端。
以下樣本示範如何為使用 Secure Store Service 進行串連的 Oracle 資料庫設定 LobSystemInstance 屬性。將 YOUR_ORACLE_NET_SERVICE_NAME_HERE 替換為 TNS net 服務名稱,並將 SECURESTORE_ORACLE_APP_ID_HERE 替換為在 Secure Store Service 中設定的公司專屬應用程式程式定義的名稱。
XML
<?xml version="1.0" encoding="utf-8" standalone="yes"?><Model xmlns="http://schemas.microsoft.com/windows/2007/BusinessDataCatalog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.microsoft.com/windows/2007/BusinessDataCatalog BDCMetadata.xsd" Name="OracleHRDB"> <LobSystems> <LobSystem Type="Database" Name="OracleHR" DefaultDisplayName="Oracle 2"> <Properties> <Property Name="WildcardCharacter" Type="System.String">%</Property> </Properties> <LobSystemInstances> <LobSystemInstance Name="Oracle HR Instance"> <Properties> <Property Name="AuthenticationMode" Type="System.String">RdbCredentials </Property> <Property Name="DatabaseAccessProvider" Type="System.String">Oracle </Property> <Property Name="RdbConnection Data Source" Type="System.String"> YOUR_ORACLE_NET_SERVICE_NAME_HERE</Property> <Property Name="SsoApplicationId" Type="System.String"> SECURESTORE_ORACLE_APP_ID_HERE</Property> <!-- Server ship <Property Name="SsoProviderImplementation" Type="System.String"> Microsoft.Office.SecureStoreService.Server.SecureStoreProvider, Microsoft.Office.SecureStoreService, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Property> --> <!-- Client Ship --> <Property Name="SsoProviderImplementation" Type="System.String"> Microsoft.Office.BusinessData.Infrastructure.SecureStore.LocalSecureStoreProvider, Microsoft.Office.BusinessData, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Property> </Properties> </LobSystemInstance> </LobSystemInstances> <Entities> <Entity EstimatedInstanceCount="10000" Name="Employee" DefaultDisplayName="Employee" Namespace="HR.OracleModel" Version="1.0.0.0"> <Properties> <Property Name="Title" Type="System.String">EName</Property> </Properties> <Identifiers> <Identifier TypeName="System.String" Name="EmployeeName" /> </Identifiers> <Methods> <Method Name="EmployeeFinder"> <Properties> <Property Name="RdbCommandText" Type="System.String"> SELECT EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO FROM SCOTT.EMP WHERE ENAME LIKE :Name ORDER BY EMPNO</Property> <Property Name="RdbCommandType" Type="System.Data.CommandType, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> Text</Property> </Properties> <FilterDescriptors> <FilterDescriptor Type="Wildcard" Name="EmployeeName" /> </FilterDescriptors> <Parameters> <Parameter Direction="In" Name=":Name"> <TypeDescriptor TypeName="System.String" IdentifierName="EmployeeName" AssociatedFilter="EmployeeName" Name="EmployeeName" > <DefaultValues> <DefaultValue MethodInstanceName="IdEnumeratorInstance" Type="System.String">%</DefaultValue> <DefaultValue MethodInstanceName="EmployeeFinderInstance" Type="System.String">%</DefaultValue> </DefaultValues> </TypeDescriptor> </Parameter> <Parameter Direction="Return" Name="Employees"> <TypeDescriptor TypeName="System.Data.IDataReader, System.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" IsCollection="true" Name="Employees"> <TypeDescriptors> <TypeDescriptor TypeName="System.Data.IDataRecord, System.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Name="Employee"> <TypeDescriptors> <TypeDescriptor TypeName="System.Decimal" Name="EMPNO" /> <TypeDescriptor TypeName="System.String" ReadOnly ="true" IdentifierName="EmployeeName" Name="ENAME" /> <TypeDescriptor TypeName="System.String" Name="JOB" /> <TypeDescriptor TypeName="System.Decimal" Name="MGR" /> <TypeDescriptor TypeName="System.DateTime" Name="HIREDATE" /> <TypeDescriptor TypeName="System.Decimal" Name="SAL" /> <TypeDescriptor TypeName="System.Decimal" Name="COMM" /> <TypeDescriptor TypeName="System.Decimal" Name="DEPTNO" /> </TypeDescriptors> </TypeDescriptor> </TypeDescriptors> </TypeDescriptor> </Parameter> </Parameters> <MethodInstances> <MethodInstance Type="Finder" ReturnParameterName="Employees" ReturnTypeDescriptorName="Employees" ReturnTypeDescriptorLevel="0" Name="EmployeeFinderInstance" > <AccessControlList> <AccessControlEntry Principal="redmond\domain users"> <Right BdcRight="Execute"/> <Right BdcRight="Edit"/> <Right BdcRight="SetPermissions"/> <Right BdcRight="SelectableInClients"/> </AccessControlEntry> </AccessControlList> </MethodInstance> <MethodInstance Type="SpecificFinder" ReturnParameterName="Employees" ReturnTypeDescriptorName="Employee" ReturnTypeDescriptorLevel="1" Name="EmployeeSpecificFinderInstance" > <AccessControlList> <AccessControlEntry Principal="redmond\domain users"> <Right BdcRight="Execute"/> <Right BdcRight="Edit"/> <Right BdcRight="SetPermissions"/> <Right BdcRight="SelectableInClients"/> </AccessControlEntry> </AccessControlList> </MethodInstance> <MethodInstance Type="IdEnumerator" ReturnParameterName="Employees" ReturnTypeDescriptorName="Employees" ReturnTypeDescriptorLevel="0" Name="IdEnumeratorInstance" > <AccessControlList> <AccessControlEntry Principal="redmond\domain users"> <Right BdcRight="Execute"/> <Right BdcRight="Edit"/> <Right BdcRight="SetPermissions"/> <Right BdcRight="SelectableInClients"/> </AccessControlEntry> </AccessControlList> </MethodInstance> </MethodInstances> </Method> <Method Name="Update" DefaultDisplayName="EmployeeUpdater"> <Properties> <Property Name="RdbCommandType" Type="System.Data.CommandType, System.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> Text</Property> <Property Name="RdbCommandText" Type="System.String"> UPDATE SCOTT.EMP SET EMPNO=:EmpNo,JOB=:Job,MGR=:Mgr,HIREDATE=:HireDate, SAL=:Sal,COMM=:Comm,DEPTNO=:DeptNo WHERE ENAME=:Name</Property> </Properties> <AccessControlList> <AccessControlEntry Principal="redmond\domain users"> <Right BdcRight="Edit" /> <Right BdcRight="Execute" /> <Right BdcRight="SetPermissions" /> <Right BdcRight="SelectableInClients" /> </AccessControlEntry> </AccessControlList> <Parameters> <Parameter Direction="In" Name=":EmpNo"> <TypeDescriptor TypeName="System.Decimal" UpdaterField="true" Name="EMPNO" /> </Parameter> <Parameter Direction="In" Name=":Name"> <TypeDescriptor TypeName="System.String" IdentifierName="EmployeeName" Name="EmployeeName" > </TypeDescriptor> </Parameter> <Parameter Direction="In" Name=":Job"> <TypeDescriptor TypeName="System.String" UpdaterField="true" Name="JOB" /> </Parameter> <Parameter Direction="In" Name=":Mgr"> <TypeDescriptor TypeName="System.Decimal" UpdaterField="true" Name="MGR" /> </Parameter> <Parameter Direction="In" Name=":HireDate"> <TypeDescriptor TypeName="System.Nullable`1[[System.DateTime, mscorlib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]" UpdaterField="true" Name="HIREDATE" /> </Parameter> <Parameter Direction="In" Name=":Sal"> <TypeDescriptor TypeName="System.Nullable`1[[System.Decimal, mscorlib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]" UpdaterField="true" Name="SAL" /> </Parameter> <Parameter Direction="In" Name=":Comm"> <TypeDescriptor TypeName="System.Nullable`1[[System.Decimal, mscorlib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]" UpdaterField="true" Name="COMM"> <Properties> <Property Name="Decimal Digits" Type="System.Int32">9</Property> </Properties> </TypeDescriptor> </Parameter> <Parameter Direction="In" Name=":Deptno"> <TypeDescriptor TypeName="System.Nullable`1[[System.Decimal, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]" UpdaterField="true" Name="DEPTNO"> <Properties> <Property Name="Decimal Digits" Type="System.Int32">9</Property> </Properties> </TypeDescriptor> </Parameter> </Parameters> <MethodInstances> <MethodInstance Type="Updater" Name="Update" DefaultDisplayName="SQLAllTypes Update"> <AccessControlList> <AccessControlEntry Principal="redmond\domain users"> <Right BdcRight="Edit" /> <Right BdcRight="Execute" /> <Right BdcRight="SetPermissions" /> <Right BdcRight="SelectableInClients" /> </AccessControlEntry> </AccessControlList> </MethodInstance> </MethodInstances> </Method> <Method Name="Delete" DefaultDisplayName="EmployeeDelete"> <Properties> <Property Name="RdbCommandText" Type="System.String"> DELETE FROM SCOTT.EMP WHERE ENAME = :Name</Property> <Property Name="RdbCommandType" Type="System.Data.CommandType, System.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> Text</Property> </Properties> <AccessControlList> <AccessControlEntry Principal="redmond\domain users"> <Right BdcRight="Edit" /> <Right BdcRight="Execute" /> <Right BdcRight="SetPermissions" /> <Right BdcRight="SelectableInClients" /> </AccessControlEntry> </AccessControlList> <Parameters> <Parameter Direction="In" Name=":Name"> <TypeDescriptor TypeName="System.String" IdentifierName="EmployeeName" Name="EmployeeName" > </TypeDescriptor> </Parameter> </Parameters> <MethodInstances> <MethodInstance Type="Deleter" Name="Delete" DefaultDisplayName="Employee Delete"> <AccessControlList> <AccessControlEntry Principal="redmond\domain users"> <Right BdcRight="Edit" /> <Right BdcRight="Execute" /> <Right BdcRight="SetPermissions" /> <Right BdcRight="SelectableInClients" /> </AccessControlEntry> </AccessControlList> </MethodInstance> </MethodInstances> </Method> </Methods> </Entity> </Entities> </LobSystem> </LobSystems></Model>