Re: chances of getting error no 87, hr = 2147221000 (CO_E_DLLNOTFOUND on SQL CE 2.0)
From: Prasanna Sampath [MSFT] (psampath_at_online.microsoft.com)
Date: 04/21/04
- Previous message: steve: "Re: sql hierarchial query"
- In reply to: Prabhu Sundar: "Re: chances of getting error no 87, hr = 2147221000 (CO_E_DLLNOTFOUND on SQL CE 2.0)"
- Next in thread: Prabhu: "Re: chances of getting error no 87, hr = 2147221000 (CO_E_DLLNOTFOUND on SQL CE 2.0)"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 21 Apr 2004 17:47:56 GMT
I would try to remove the CoInitializeEx and CoCreateInstance calls out of
COLEDBHelper::Open. Move these 2 calls to an outer function. You can have a
pointer on the DSO object at all times and just use that open and close
your database instead of CoCreating every 2 minutes.
-Prasanna
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| From: Prabhu Sundar <prabhu.sundarraj@patni.com>
| References: <e6RvBCjJEHA.3544@TK2MSFTNGP10.phx.gbl>
| X-Newsreader: AspNNTP 1.50 (ActionJackson.com)
| Subject: Re: chances of getting error no 87, hr = 2147221000
(CO_E_DLLNOTFOUND on SQL CE 2.0)
| Mime-Version: 1.0
| Content-Type: text/plain; charset="us-ascii"
| Content-Transfer-Encoding: 7bit
| Message-ID: <eO1nL3oJEHA.1340@TK2MSFTNGP12.phx.gbl>
| Newsgroups: microsoft.public.sqlserver.ce
| Date: Mon, 19 Apr 2004 21:13:10 -0700
| NNTP-Posting-Host: actionjackson133.dsl.frii.net 216.17.147.133
| Lines: 1
| Path:
cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12
phx.gbl
| Xref: cpmsftngxa10.phx.gbl microsoft.public.sqlserver.ce:12131
| X-Tomcat-NG: microsoft.public.sqlserver.ce
|
| Following is the code I am getting error, here I am opening the database
| after every 2 minutes
|
|
|
| /***********************************************************************
| ******/
| /**
| *PURPOSE : Open method for opening the connection to the database.
| *PASSED : None
| *RETURNS : bool, Success or failure uis conveyed to the caller. true
| if
| successful.
| *NOTES : This is the static routine to initialize the connection.
| Ideally the connection should be initialized outside of such a wrapper
| class and be passed to the class in the constructor. However, provision
| of such a static routine provides the alternate means to do the same.
| Care should be taken that this routine is called only once for a
| partiular db connection needed. It should be ideally called in the
| InitInstance() of the application. Also,the other static members
| initialized in this static routine should NOT be manupulated outside
| this class. Thus any instance of this class can use one and only one
| conection to the database. */
| /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
| * * */
|
|
| bool COLEDBHelper::Open(const CString& Database, const CString& userID,
| const CString& passWord,
| const CString& tempLoc, HRESULT & errCode)
| {
|
| if(COLEDBHelper::m_bIsOpen)
| {
| return true;
| }
|
| HRESULT hr;
| errCode = S_OK;
|
| ASSERT(COLEDBHelper::m_pIDBInitialize==NULL);
|
| // Init COM library
| hr = ::CoInitializeEx(NULL,COINIT_MULTITHREADED);
|
| if(FAILED1(hr))
| {
| errCode = hr;
| return false;
| }
|
| hr = CoCreateInstance(CLSID_SQLSERVERCE_2_0, NULL,
| CLSCTX_INPROC_SERVER, IID_IDBInitialize,
| (void**)&(COLEDBHelper::m_pIDBInitialize));
|
| if(FAILED1(hr))
| {
| errCode = hr;
| return false;
| }
|
|
| ASSERT(m_pIDBInitialize);
|
| DBPROP InitProperties[8],InitProperties1[2];
| DBPROPSET rgInitPropSet[2];
|
| // Initializing the database file
| InitProperties[0].dwPropertyID = DBPROP_INIT_DATASOURCE;
| InitProperties[0].dwOptions = DBPROPOPTIONS_REQUIRED;
| V_VT(&(InitProperties[0].vValue)) = VT_BSTR;
| V_BSTR(&(InitProperties[0].vValue)) = SysAllocStringLen(Database,
| wcslen(Database));
|
| //SSCE Password specific property.
| InitProperties1[0].dwPropertyID = DBPROP_SSCE_DBPASSWORD;
| InitProperties1[0].dwOptions = DBPROPOPTIONS_REQUIRED;
| InitProperties1[0].vValue.vt = VT_BSTR;
| InitProperties1[0].vValue.bstrVal = SysAllocString(passWord);
|
| //Specify a Temp Folder instead of default \\Temp folder which
| //Sql CE takes for storing the temp files
| InitProperties1[1].dwPropertyID = DBPROP_SSCE_TEMPFILE_DIRECTORY;
| InitProperties1[1].dwOptions = DBPROPOPTIONS_OPTIONAL;
| InitProperties1[1].vValue.vt = VT_BSTR;
| InitProperties1[1].vValue.bstrVal = SysAllocString(tempLoc);
|
|
| // Create the structure containing the properties
| rgInitPropSet[0].rgProperties = InitProperties;
| rgInitPropSet[0].cProperties =
| sizeof(InitProperties)/sizeof(InitProperties[0]);
| rgInitPropSet[0].guidPropertySet = DBPROPSET_DBINIT;
|
|
| // Initialize provider-specific property set
| rgInitPropSet[1].guidPropertySet = DBPROPSET_SSCE_DBINIT;
| rgInitPropSet[1].rgProperties = InitProperties1;
| rgInitPropSet[1].cProperties =
| sizeof(InitProperties1)/sizeof(InitProperties1[0]);
|
| // Set initialization properties.
| hr =
| m_pIDBInitialize->QueryInterface(IID_IDBProperties,(void**)&(COLEDBHelpe
| r::m_pIDBProperties));
|
| if(FAILED1(hr))
| {
| errCode = hr;
| return false;
| }
|
| ASSERT(m_pIDBProperties);
|
| hr =
| COLEDBHelper::m_pIDBProperties->SetProperties(sizeof(rgInitPropSet)/size
| of(rgInitPropSet[0]), rgInitPropSet);
|
| //..... SysFreeString calls to go here
| if(FAILED1(hr))
| {
| errCode = hr;
| return false;
| }
|
| hr = COLEDBHelper::m_pIDBInitialize->Initialize();
| if(FAILED1(hr))
| {
| TRACE(L"\nDatabase Initialize failed.\n");
| errCode = hr;
| return false;
| }
|
| // OLE DB session object.
| hr =
| COLEDBHelper::m_pIDBInitialize->QueryInterface(IID_IDBCreateSession,(voi
| d**) &(COLEDBHelper::m_pIDBCreateSession));
| if(FAILED1(hr))
| {
| TRACE(L"\nSession creation failed.\n");
| errCode = hr;
| return false;
| }
|
| hr = COLEDBHelper::m_pIDBCreateSession->CreateSession(NULL,
| IID_IUnknown, &(COLEDBHelper::m_pIUnknownSession));
| ASSERT(m_pIDBCreateSession);
|
| hr =
| COLEDBHelper::m_pIUnknownSession->QueryInterface(IID_IDBCreateCommand,
| (void**) &(COLEDBHelper::m_pIDBCreateCommand));
| if(FAILED1(hr))
| {
| TRACE(L"The session failed to instanciate the command object.");
| errCode = hr;
| return false;
| }
|
|
| COLEDBHelper::m_bIsOpen = true;
|
| SysFreeString(V_BSTR(&(InitProperties[0].vValue)));
| SysFreeString(V_BSTR(&(InitProperties1[0].vValue)));
| SysFreeString(V_BSTR(&(InitProperties1[1].vValue)));
|
| return true;
| }
|
|
|
|
| *** Sent via Developersdex http://www.developersdex.com ***
| Don't just participate in USENET...get rewarded for it!
|
- Previous message: steve: "Re: sql hierarchial query"
- In reply to: Prabhu Sundar: "Re: chances of getting error no 87, hr = 2147221000 (CO_E_DLLNOTFOUND on SQL CE 2.0)"
- Next in thread: Prabhu: "Re: chances of getting error no 87, hr = 2147221000 (CO_E_DLLNOTFOUND on SQL CE 2.0)"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|