MDAC 2.5 SDK - OLE DB Programmer's Reference
OLE DB Core Components Interfaces


 

IDataInitialize::LoadStringFromStorage

Loads a connection string.

HRESULT LoadStringFromStorage(
   LPCOLESTR     pwszFileName,
   LPCOLESTR *   ppwszInitializationString);

Parameters

pwszFileName [in]

Name of the file.

ppwszInitializationString [out]

On exit, *ppwszInitializationString will contain the connection string.

Return Code

S_OK

The method succeeded.

E_FAIL

A provider-specific error occurred.

E_INVALIDARG

pwszFileName was a null pointer.

ppwszInitializationString was a null pointer.

STG_E_FILENOTFOUND

The file indicated by pwszFileName was not found.

STG_E_ACCESSDENIED

The caller has insufficient permission to open the file.

The file is already open and locked for writing.

STG_E_INVALIDNAME

pwszFileName was an invalid file name.

STG_E_INVALIDHEADER

pwszFileName was a file that is not a UDL format file.

Comments

The ppwszInitializationString retrieved using this method will have any leading or trailing spaces trimmed from it. Hence, the string might not be exactly the same one as written using the IDataInitialize::WriteStringToStorage method. For example, passing in the string

   "   Provider=MSDASQL.1; User ID = sa   " 

will be returned as

   "Provider=MSDASQL.1; User ID = sa"

When using .udl files to establish a connection, add "Udl Pooling" to the registry under the "SOFTWARE\Microsoft\DataAccess" key to improve performance. A Cache Size value greater than 0 (Cache Size=1) will enable the feature. A value of 100 is recommended.