Re: Not enough storage is available to process this command
- From: "tk72" <t_karlsson72@xxxxxxxxxxx>
- Date: 24 Aug 2005 07:33:58 -0700
tk72 wrote:
> I have written a DLL in C++/ATL (Visual Studio 6.0) that connects to
> different databases using ADO smart pointers (_ConnectionPtr and
> _RecordsetPtr). I am connecting to one MS Access database among
> others, and it is that connection that gives me a headache. I can call
> the function in this DLL with the same parameters about 1000 times
> before an exception is thrown with the error in the subject. The code
> to open each connection is:
>
> ******** CODE *********
>
> bool CPE::OpenConnection(int connIndx)
> {
> HRESULT hr = S_OK;
> try
> {
> if(m_connArr[connIndx] == NULL)
> {
> hr = m_connArr[connIndx].CreateInstance(__uuidof(Connection));
> if(hr != S_OK)
> {
> return false;
> }
> }
>
> if(hr == S_OK && m_connArr[connIndx]->State != adStateOpen)
> {
> m_connArr[connIndx]->CursorLocation = adUseClient;
> hr = m_connArr[connIndx]->Open(m_connStrArr[connIndx], "", "",
> -1);
> if(hr != S_OK)
> {
> return false;
> }
> }
> }
> catch(_com_error &err)
> {
> return false;
> }
> return true;
> }
>
> ******** CODE *********
>
> The connIndex is an index into both an array of _ConnectionPtr
> (m_connArr) objects and an array of _bstr_t:s (m_connStrArr) that holds
> the connections strings for the corresponding connection. The call to
> open the recordset goes like:
>
> ******** CODE *********
>
> if(pRs == NULL)
> {
> hr = pRs.CreateInstance(__uuidof(Recordset));
> }
>
> pRs->CursorLocation = adUseClient;
>
> pRs->Open(sql, m_connArr[ConnIndex].GetInterfacePtr(), adOpenStatic,
> adLockOptimistic, -1);
>
> pRs->putref_ActiveConnection(NULL);
>
> ******** CODE *********
>
> Both sql and ConnIndex are parameters to the function where this call
> is made from.
>
> Can anyone see anything wrong in this code, or at least have any ideas
> how to go about tracking down the problem further? I have debug code
> that logs all open and close of the recordsets and connections, and
> they do match after each call to the DLL. I am only opening/closing
> each of the connections once during the lifetime of the DLL. Does a
> connection have a "life span", so I need to close it and re-open it
> once in a while. One obvious problem would be that there isn't enough
> disk space or memory, but there are plenty of both, so I don't think
> that is it.
>
> Any help would be much appreciated,
>
> TK
I forgot to point out that the error occurs on the line where the
recordset is opened.
Thanks,
TK
.
- Follow-Ups:
- References:
- Prev by Date: ADODB Command Memory Leak - Source Sample
- Next by Date: Re: Trapping CommitTrans - returns success even when failed!
- Previous by thread: Not enough storage is available to process this command
- Next by thread: Re: Not enough storage is available to process this command
- Index(es):
Relevant Pages
|
|