IPropertySetPtr pPropertySet = NULL; IWorkspaceFactory2Ptr pWorkspaceFactory2 = NULL; IWorkspacePtr pWorkspace = NULL; ISqlWorkspacePtr pSqlWorkspace = NULL; OLE_HANDLE hWnd = 0; HRESULT hr = S_OK; // Create the connection Property Set pPropertySet.CreateInstance(CLSID_PropertySet); // At ArcGIS 10.0, this parameter specified either "oracle10g" or "oracle11g" // (when used with the SqlWorkspaceFactory class). // At ArcGIS 10.1, this parameter is apparently to just be "oracle" // (when used with the SdeWorkspaceFactory class). hr = pPropertySet->SetProperty( CComBSTR(_T("DBCLIENT")), CComVariant(CComBSTR(_T("oracle"))) ); // This appears to be a new property at the ArcGIS 10.1 level. // It appears to replace the "SERVERINSTANCE" propety used in ArcGIS 10.0 // to call the ->Open() method on the SqlWorkspaceFactory. hr = pPropertySet->SetProperty( CComBSTR(_T("DB_CONNECTION_PROPERTIES")), CComVariant(CComBSTR(_T("sde:oracle11g:hydra04"))) ); hr = pPropertySet->SetProperty( CComBSTR(_T("AUTHENTICATION_MODE")), CComVariant(CComBSTR(_T("DBMS"))) ); hr = pPropertySet->SetProperty( CComBSTR(_T("USER")), CComVariant(CComBSTR(_T("scott"))) ); hr = pPropertySet->SetProperty( CComBSTR(_T("PASSWORD")), CComVariant(CComBSTR(_T("zzzzzzz"))) ); // Create the SDE Workspace factory pWorkspaceFactory2.CreateInstance(CLSID_SdeWorkspaceFactory); // Open the SDE workspace with the PropertySet hr = pWorkspaceFactory2->Open(pPropertySet, hWnd, &pWorkspace); // QI to get the ISqlWorkspace interface pointer. // Once gaining access to this ISqlWorkspace interface pointer, // the rest of the processing for creating a Query Layer seems to be // consistent with the ArcGIS 10.0 Query Layer processing. pSqlWorkspace = pWorkspace;
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.