Re: C++ support for ADO



Source=Finances 2006 ? As finance bods do absolutely everything with Excel
are you trying to open a work-book? Because if you are, you need the
Extended Properties parameter. The following works in VS6.

CString sTx, sFilePath="c:\Accounts2006.xls";
_bstr_t a,b;
_ConnectionPtr pConn = NULL;
TESTHR(pConn.CreateInstance( __uuidof( Connection )));
sTx.Format("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=%s; Extended
Properties=\"Excel 8.0;\"",sFilePath);
pConn->Open(sTx.AllocSysString(),a,b,0L);

seabee

Thanks for the overview, it was enlightening.

In answer to your question I'm interested in ADO not the ADO.net.

I have the following code compiled and running up to the OPEN Connection:


//*************************************************
bool CDataBase::Open(CString userName, CString password, CString cnnStr)
//*************************************************
{
HRESULT hr;
_bstr_t errorMsg;
_bstr_t _userName, _password, _cnnStr;
_userName=LPCTSTR(userName);
_password=LPCTSTR(password);
_cnnStr=LPCTSTR(cnnStr);

// Create a connection object
ADODB::_ConnectionPtr connection;
hr = connection.CreateInstance(__uuidof(ADODB::Connection));

// Create a record set object
ADODB::_RecordsetPtr recordset;
hr = recordset.CreateInstance(__uuidof(ADODB::Recordset));

// Open a connection to a data base
connection->CursorLocation = ADODB::adUseClient;

try {hr=connection->Open(L"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=Finances 2006;", L"admin", L"049846234640",
ADODB::adConnectUnspecified); }
catch(_com_error &e)
{
// Handle errors
errorMsg=e.Description();
return 0;
}


At this point I get the errorMsg of :
"Cannot start your application. The workgroup information file is missing
or
opened exclusively by another user."

Not familiar with workgroup information file.

Is this related to the Initial Catalog command?

If so how do you set it up? Or where do you find it?

Where can I get the class info on ADODB::_ConnectionPtr and
ADODB::_RecordsetPtr ?

And how can I convert _bstr_t to a CString?

These are a few of the areas I'm have difficulty finding.

Any help you can give would be greatly appreciated.

Thanks, Nei


"Ralph" wrote:


"Neil B" <NeilB@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:52804A7A-CC60-4F1D-9FBE-E472B642C0E4@xxxxxxxxxxxxxxxx
I'm in the process of updating an app from ODBC to ADO in VS using C++
(MFC).

I'm use to having the interface classes defined.
In my attempts to work with ADO I can't find information on classes and
methods that I'm executing.

I'm told that ADO is the strategic direction of MS.
What am I missing here???

It's no fun programming in the blind!!!

Can anyone provide some direction?

Thanks, Neil

The issue you are having is not that little information is available, it
is
simply that it is located under something that probably isn't immediately
recognizeable as useful. Also because of the amazing versatility of C++
there are more that one way to work with "ADO".

[First, are you using .Net (C++/cli, ADO.Net)? If so, this this newsgroup
isn't for you. It sounds like you are using classic MFC and plain-ol-ADO,
but I just wanted to make sure. <g>]

ADO is an ActiveX Data Access Library (COM) that serves as a wrapper for
OLE
DB. Stickly speaking, this is the true "ADO". It was designed for
'higher-level languages' such as VB, VBA, etc.
You can use ADO components directly from C++, a la VB, by using the
#import
statement and accessing the library just as you would any other COM
component.

For this practically any ADO samples, books, and articles are useful. And
there are a ton of them.

When using MFC and DAO/ODBC you used the CDao... data classes. There are
also COle... data classes for working with ADO/OLE DB. (They sort of wrap
the ADO wrappers. Confused yet? <g>) So you can use "ADO" in this way as
well, though are a bit limited compared to the full featured ADO library.
(Poor Error handling is biggest fault.)

Look for information on COle.... classes.

You can also use the OLE SDK. Which allows you to more directly access
ADO
and OLE DB interfaces/objects. It resolves the Error handling problems,
but
is sort of an odd mix between two worlds. There is probably the least
amount
of information using this method.

Check out "OLE DB, adoid.h, and adoint.h".

Last but likely best is accessing OLE DB directly and skip using ADO -
this
method will give the best performance and the most control. ie, write
your
own "ADO".

Look for "VC++ OLE DB programming"

hth
-ralph


.



Relevant Pages

  • Is it possible to use ADO in threaded service app?
    ... I have declared ADO DB connection and query for each thread, ... -When I use as ole provider Microsoft Jet 4.0 (for storing data use Access ...
    (borland.public.delphi.database.ado)
  • Re: C++ support for ADO
    ... TESTHR(pConn.CreateInstance(__uuidof(Connection))); ... In answer to your question I'm interested in ADO not the ADO.net. ... data classes for working with ADO/OLE DB. ... You can also use the OLE SDK. ...
    (microsoft.public.data.ado)
  • Re: C++ support for ADO
    ... In answer to your question I'm interested in ADO not the ADO.net. ... I have the following code compiled and running up to the OPEN Connection: ... data classes for working with ADO/OLE DB. ... You can also use the OLE SDK. ...
    (microsoft.public.data.ado)
  • Re: C++ support for ADO
    ... TESTHR(pConn.CreateInstance(__uuidof(Connection))); ... In answer to your question I'm interested in ADO not the ADO.net. ... Not familiar with workgroup information file. ... You can also use the OLE SDK. ...
    (microsoft.public.data.ado)
  • Re: ODBC/OLE DB Connection Pool
    ... > connection be kept open for the application as this will serialize all ... threads ONCE they are returned to the pool. ... > Tips for ADO Users ... > The ADO Connection object implicitly uses IDataInitialize. ...
    (microsoft.public.inetserver.asp.db)