Re: Error 0x800A0BB9 When Reconnecting in same process instance



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 database cannot be converted to 2003 because it cannot be opened in
the
primary application (3rd party) the database is for. So cross the
converting
the database thing off your list(s) immediately.

Generally the process flow for users is to open the database, run a
process
against the data then terminate the application. I recently added a
feature
to compact the database but I have to close the connection in order to
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
of
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




.



Relevant Pages

  • Re: Embedded SQL calling another Embedded SQL program
    ... The problem is when I disable the connect/disconnect on program B, ... no data is loaded because it will say that the database is not ... >> Program A is a standalone SQLRPG program which simply displays a subfile. ... >> Program A and Program B both have standard CONNECT RESET and DISCONNECT ...
    (comp.sys.ibm.as400.misc)
  • Re: Retrieving by program the parameter list of a stored procedure ?
    ... in an ADO ... > database, but is it possible to know the ... Have a search in google for OpenSchema. ... Get a copy of AdoAnywhere Browser FREE if you register for the forum ...
    (borland.public.delphi.database.ado)
  • Re: ANN: AnySQL Maestro (freeware cross-database tool)
    ... Also OpenSchema knows nothing about DBMS specific objects, such as tablespaces, jobs, partitions, full-text catalogs, etc. ... Also AnySQL Maestro strongly depends from OLE DB Provider / ODBC Driver you have installed. ... Do you have a product like AnySQL where I can connect to a variety of database vendors and have full database management? ...
    (borland.public.delphi.thirdpartytools.general)
  • Re: ADO AV
    ... > That is possible I have not used openSchema with any datbases that are ... Obviously the older database is not 100% ADO compliant. ...
    (borland.public.delphi.database.ado)
  • Re: ADO AV
    ... That is possible I have not used openSchema with any datbases that are that old. ... Try it on an Access 2000 database and find out ... Brian Bushay ...
    (borland.public.delphi.database.ado)