Re: Accessing text / csv files using ADO in C++
- From: "Ralph" <nt_consulting64@xxxxxxxxx>
- Date: Mon, 3 Mar 2008 23:00:50 -0600
"Venkatesh" <Venkatesh@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:281AD548-FAB9-4B99-ACA2-0B003E1B552F@xxxxxxxxxxxxxxxx
Hi Ralph,more
Actually I wasn't using an uninitialised object, because soon after the
declaration of spConn you'll find code to CreateInstance that creates an
object. However, I did try what you suggested and this time I got a much
informative error "CoInitialize has not been called" instead of "Invalidand
pointer" !! I had forgotten to add a call to CoInitialize, so I added it,
then I crossed that stage. Then I got a few other errors because of otherin
problems (such as using a blank user name instead of "Admin"), and when I
solved them, things started working.
So going back, it turns out that the behaviour of:
(1)
_ConnectionPtr spConn;
spConn.CreateInstance(__uuidof(Connection));
is significantly different from that of:
(2)
_ConnectionPtr spConn(__uuidof(Connection));
though internally the constructor called in (2) calls CreateInstance used
(1). This difference is because CreateInstance returns hr, so we'reexpected
to check it. But the ctor in (2) calls _com_issue_error which internallydoes
a throw.
Thanks, Ralph.
Venkatesh
Thanks, for replying and setting me straight on what was actually happening.
I have used the latter construct for so long it became "boilerplate" and I
forgot why I did it that way. <g>
-ralph
.
- References:
- Re: Accessing text / csv files using ADO in C++
- From: Ralph
- Re: Accessing text / csv files using ADO in C++
- From: Venkatesh
- Re: Accessing text / csv files using ADO in C++
- Prev by Date: Re: Accessing text / csv files using ADO in C++
- Next by Date: Re: browsing for sqlservers
- Previous by thread: Re: Accessing text / csv files using ADO in C++
- Next by thread: Re: browsing for sqlservers
- Index(es):