Re: Error 0x800A0BB9 When Reconnecting in same process instance
- From: harrier <harrier@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 1 Feb 2007 07:13:01 -0800
Here is the connect/disconnect methods. If I comment out the OpenSchema
calland associated code in Connect(), the error doesn't occur. I can
Connect/Disconnect all day. When I call OpenSchema, successive calls to
Connect fail.
HRESULT CTrackDoc::Connect()
{
_bstr_t bstrConnStr;
HRESULT hr = S_OK;
if (m_pConnection != NULL)
return S_OK;
hr = m_pConnection.CreateInstance(__uuidof(Connection));
if (FAILED(hr))
{
TRACE("Error: 0x%X\n", hr);
return hr;
}
bstrConnStr = L"Provider=Microsoft.Jet.OLEDB.4.0;";
bstrConnStr += L"Data Source=";
bstrConnStr += m_csDatabasePath.AllocSysString();
bstrConnStr += L";Jet OLEDB:Engine Type=3;";
try
{
hr = m_pConnection->Open(bstrConnStr, L"", L"", -1);
}
catch(_com_error& err)
{
#if defined _DEBUG
AfxMessageBox(err.ErrorMessage(),
MB_ICONSTOP | MB_OK, 0);
TRACE("Error: %X\n", err.Error());
#endif
}
if (FAILED(hr))
return hr;
try
{
_RecordsetPtr pRecordset = NULL;
_variant_t vValue;
CString csTableName;
int nTables = 0;
pRecordset = m_pConnection->OpenSchema(adSchemaTables);
while (!pRecordset->EndOfFile && SUCCEEDED(hr))
{
vValue = pRecordset->GetFields()->GetItem("TABLE_NAME")->GetValue();
csTableName = vValue.bstrVal;
if (csTableName.CompareNoCase("Athlete") == 0)
++nTables;
else if (csTableName.CompareNoCase("Bracket") == 0)
++nTables;
else if (csTableName.CompareNoCase("Divisions") == 0)
++nTables;
else if (csTableName.CompareNoCase("Entry") == 0)
++nTables;
else if (csTableName.CompareNoCase("Event") == 0)
++nTables;
else if (csTableName.CompareNoCase("Meet") == 0)
++nTables;
else if (csTableName.CompareNoCase("Relay") == 0)
++nTables;
else if (csTableName.CompareNoCase("Team") == 0)
++nTables;
hr = pRecordset->MoveNext();
}
pRecordset->Close();
pRecordset = NULL;
if (nTables != 7)
{
CString csMsg;
csMsg = "The database file opened does not appear to be a valid
database.\n";
csMsg += "The database will be closed. Please select a different file.";
AfxMessageBox(csMsg, MB_ICONSTOP | MB_OK, 0);
m_pConnection->Close();
m_pConnection = NULL;
return E_FAIL;
}
}
catch(_com_error& err)
{
#if defined _DEBUG
AfxMessageBox(err.Description(), MB_ICONSTOP | MB_OK, 0);
TRACE("Error: %X\n", err.Error());
#endif
}
hr = this->LoadSessions();
if (FAILED(hr))
AfxMessageBox("The session list cannot be displayed.", MB_ICONWARNING |
MB_OK, 0);
return hr;
}
HRESULT CTrackDoc::Disconnect()
{
try
{
if (m_pConnection != NULL)
{
HRESULT hr = m_pConnection->Close();
// Reinitialize the member variables now the connection is down.
m_pConnection = NULL;
this->SetSession(UNSELECTED);
m_bUseDivisions = false;
return hr;
}
}
catch(_com_error& err)
{
TRACE("Exception during disconnect from database 0x%X : %s\n",
err.Error(), err.ErrorMessage());
m_pConnection = NULL;
}
return S_OK;
}
"Ralph" wrote:
.
"harrier" <harrier@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:2DE00EE8-DE55-47CF-8C6C-CF855A971033@xxxxxxxxxxxxxxxx
I have an application in C++ 2003 that connects to an Access 95 database.the
The database cannot be converted to 2003 because it cannot be opened in
primary application (3rd party) the database is for. So cross theconverting
the database thing off your list(s) immediately.process
Generally the process flow for users is to open the database, run a
against the data then terminate the application. I recently added afeature
to compact the database but I have to close the connection in order toof
perform the compact. After compacting I reconnect to the database and get
the following error on the Connect call:
Error: 0x800A0BB9
Arguments are of the wrong type, are out of acceptable range, or are in
conflict with one another.
I've tracked down that if I comment out a call to Connection.OpenSchema()
the problem goes away. What I do is call OpenSchema and look at the list
tables. There are seven table names I look for to ensure it's a valid
application database as opposed to a generic MDB file.
Any ideas?
-harrier
Not enough information for more than a couple of hints.
Most of the time the error is exactly what it is reporting - some place you
have confused datatypes, perhaps using a long where a string is required, an
array instead of a string, etc.
This is easy to do as data items like recordset values are Variants - often
ETC will allow a particular datatype to work in some contexts but not in
others.
It is also possible to get into issues when using 'newer' data access
libraries/engines/providers with 'older' database formats. See if this sheds
some light...
http://support.microsoft.com/kb/303528/
-ralph
- Prev by Date: Re: Oracle 9i <> ADO
- Next by Date: Accessing SQL Servers in the DMZ
- Previous by thread: Re: Oracle 9i <> ADO
- Next by thread: Accessing SQL Servers in the DMZ
- Index(es):
Relevant Pages
|
|