[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ms-atl
Subject:    Re: ADO 2.5 With ATL COM
From:       "Ethan J. Brown" <development () EASTPOINTSYSTEMS ! COM>
Date:       2000-06-30 15:55:08
[Download RAW message or body]


Nayan -

I have not tried opening from a persisted XML recordset, but I have opened
up recordsets persisted as regular old text.  I found that the MSDN
documentation was pretty flaky, but with enough experimentation, and
searching around the web, I got it to work.

For the VB optional, but C++ mandatory parameters you need to define some
empty variables:

//empty smart pointers
_variant_t  vtEmpty (DISP_E_PARAMNOTFOUND, VT_ERROR);
_bstr_t     bstrEmpty(L"");


For the text driver anyway, the directory in which the text files are
located is "DefaultDir" and you perform queries against this directory.  So
let's say that I've got a file named test.csv.  You would open a recordset
with a SQL query like "SELECT * from test.csv". (It should be noted that in
my example connUpload is a _com_ptr_t for the ADOConnection class using the
_Connection interface, and rsUpload a _com_ptr_t for the ADORecordset class
using the _Recordset interface - smart pointers generated from #import'ing
msado15.dll.  strCnn is a _bstr_t, and finder is just a CFileFind that I use
to enumerate through all text files in a particular dir)


/// Our connection string to open up the directory
strCnn = "DefaultDir=";
strCnn += szSendPath;
strCnn += ";Driver={Microsoft Text Driver (*.txt;
*.csv)};Extensions=asc,csv,tab,txt;FIL=text;MaxBufferSize=2048;";

//open the connection
connUpload->Open(strCnn, "", "", adConnectUnspecified);

strSelect = _T("Select * From ");
strSelect += (LPCTSTR) finder.GetFileName();
//::MessageBox(NULL, strSelect, _T("Select Statement"), MB_OK);
//client-side cursor
rsUpload->CursorLocation = adUseClient;
//open up the recordset
rsUpload->Open(strSelect, connUpload.GetInterfacePtr(), adOpenForwardOnly,
adLockBatchOptimistic, -1);


That should do it.  I'd imagine XML wasn't too different considering its
just text as well.  Let me know if you get it working, and if there were any
quirks you came across when getting it working.


Ethan J. Brown

----------------------------------------------------------------
Users Guide http://msdn.microsoft.com/workshop/essentials/mail.asp
contains important info including how to unsubscribe.  Save time, search
the archives at http://discuss.microsoft.com/archives/index.html

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic