Problem accessing Oracle with OLE DB templates

Problem accessing Oracle with OLE DB templates

Post by Alexander Gladko » Sat, 05 Jun 1999 04:00:00



 I'm trying to access Oracle database using OLE DB templates. As an
example I'm  running DBViewer
taken from MSDN OLE DB Templates Samples topic. When I run the compiled
sample directly, it works just fine, but when I try to execute it in the
debug mode from VC IDE , it throws "First-chance  exception in
DBViewer.exe (NTDLL.DLL) : Invalid handle 0xC0000008" when trying to
connect to the server.
However I didn't have any problem accessing local databases with the
same sample run in debug mode.
I'm new to OLE DB, couldn't someone please explain me what is wrong.

Thanks.

 
 
 

1. How to manage Db access with OLE DB Consumer Templates in COM

Hi

I was curious what is the best and efficient way to manage db access
that
I have in COM object using OLE DB Consumer Templates.

The way I was thinking was to open the db on FinalConstruct of the
object?
When the user wants a new record - create a new recordset?

I'm not sure how to manage clean-up?

How do I close or destroy a rowset and should I have the user do this
before a new recordset is needed?

How do you close the database connection? I was going to put it in the
FinalConstruct.

Below I have the Open and OpenRowset

Thanks
Steve

class Cschedule : public CTable<CAccessor<CscheduleAccessor> >
{
public:

 HRESULT Open(BSTR UserKey)
 {
  HRESULT  hr;

  hr = OpenDataSource();
  if (FAILED(hr))
   return hr;

  return OpenRowset(UserKey);
 }

 HRESULT OpenDataSource()
 {
  HRESULT  hr;
  CDataSource db;
  CDBPropSet dbinit(DBPROPSET_DBINIT);

  dbinit.AddProperty(DBPROP_AUTH_CACHE_AUTHINFO, true);
  dbinit.AddProperty(DBPROP_AUTH_ENCRYPT_PASSWORD, false);
  dbinit.AddProperty(DBPROP_AUTH_MASK_PASSWORD, false);
  dbinit.AddProperty(DBPROP_AUTH_PASSWORD, OLESTR(""));
  dbinit.AddProperty(DBPROP_AUTH_USERID, OLESTR("Admin"));
  dbinit.AddProperty(DBPROP_INIT_DATASOURCE, OLESTR("schedule.mdb"));
  dbinit.AddProperty(DBPROP_INIT_MODE, (long)16);
  dbinit.AddProperty(DBPROP_INIT_PROMPT, (short)4);
  dbinit.AddProperty(DBPROP_INIT_PROVIDERSTRING, OLESTR(""));
  dbinit.AddProperty(DBPROP_INIT_LCID, (long)1033);
  hr = db.Open(_T("Microsoft.Jet.OLEDB.4.0"), &dbinit);
  if (FAILED(hr))
   return hr;

  return m_session.Open(db);
 }

 HRESULT OpenRowset(BSTR UserKey)
 {

  CComBSTR sqlBSTR;

  sqlBSTR = "SELECT * FROM ";
  sqlBSTR += "schedule";
  sqlBSTR += " WHERE UserKey1 = '";
  sqlBSTR += UserKey;
  sqlBSTR += "'";

  USES_CONVERSION;

  return CTable<CAccessor<CscheduleAccessor> >::Open(m_session,
_T(W2A(sqlBSTR)));

 }
 CSession m_session;

2. NC-RALEIGH-105602--PC-Visual Basic-ORACLE-VB/Oracle Web Developer

3. VB30: Accessing OLE-field in ACCESS-DB via OLE-VBX

4. buying CALS

5. OLE DB vs ODBC for Oracle DB access

6. Is there a limit to the number of scripts?

7. OLE DB consumer template - How to INSERT

8. OLE DB consumer templates and stored procs

9. OLE DB ATL Templates. HELP Please

10. Variable number of parameters for OLE DB consumer template

11. OLE DB Templates

12. OLE DB Templates and empty queires