Re: Accessing text / csv files using ADO in C++




"Venkatesh" <Venkatesh@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:BDA5F613-C960-454F-AD1B-D95B66AC9422@xxxxxxxxxxxxxxxx
ADO may not be the best way of accessing data when developing in C++, yet
can
somebody tell me how to access a csv file (comma-separated values) using
ADO
in C++. The following code gives me an error "Invalid pointer" when I call
the Open method of the ADO Connection object.

_ConnectionPtr spConn;
spConn.CreateInstance(__uuidof(Connection));
spConn->Open(L"Driver={Microsoft Text Driver (*.txt;
*.csv)};Dbq=C:\\;Extensions=csv,txt;", _bstr_t(L""), _bstr_t(L""),
adConnectUnspecified );

I get the same error even when Open() is called like this:

spConn->Open(L"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\;Extended
Properties=\"text;HDR=YES;FMT=Delimited(,)\"", _bstr_t(L""), _bstr_t(L""),
adConnectUnspecified );

I actually got these two variants for Open() from some VB samples, so I
don't know if I can use that way here. Of course, in VB, the last three
parameters to Open() are optional, so I passed blank values etc here.

try
_ConnectionPtr spConn(__uuidof(Connection));

You are trying to call a method on an uninitialized object.
After you have a Connection object you can use the Errors Collection to
deliminate additional problems.

-ralph


.



Relevant Pages

  • Re: Exchange 2003 ADO SELECT performance
    ... You will want to open an ADO connection object and pass it to your Rec.Open ... > I have written a application that, among other things, updates ... Dim RS As New ADODB.Recordset ...
    (microsoft.public.exchange.development)
  • RE: connecting to a SQL2000 Server using Windows authentication
    ... I'll leave it up to you to do a little light reading in MSDN concerning the ADO Connection Object. ... you should be able to check the State property of the connection object to see if you are connected. ... to this end i have set up a dev server to look at this problem. ...
    (microsoft.public.vb.database.ado)
  • Re: How do I know a query is finished?
    ... query is finished I want a message box to say "Update complete" ... You could use an ADO Connection object to run the SQL command ...
    (microsoft.public.access.formscoding)
  • Re: Yes, very complex problem. ASP code attached
    ... Yes, it is failing on the open method, if ... >> not of the connection object, then the recordset object. ... Are you saying the error ...
    (microsoft.public.inetserver.asp.db)
  • RDO Connection <--> ADO Connection
    ... Is it possible to successfully pass an instance of an RDO connection object to an ADO connection object? ... is there a conversion utility that will allow you to do this? ...
    (microsoft.public.data.ado)