Wrox Home  
Search P2P Archive for: Go

  Return to Index  

activex_data_objects thread: Text file provider in C++


Message #1 by "Jeff Haas" <haas_jeff@h...> on Sun, 24 Feb 2002 22:42:46
How can I access a text file via ADO using the Microsoft Text file 

provider found in MicroSoft Jet from Visual C++?



I have the following code which throws an exception on the last line:



_ConnectionPtr pConn=NULL;

HRESULT hr=pConn.CreateInstance(__uuidof(Connection));

_bstr_t conn(L"Provider=MSDASQL;DSN=MyDataName");

hr=pConn->Open(conn,"","",NULL);



_bstr_t Connect("myfile.txt");

_bstr_t Source("");

_RecordSetPtr pRs=NULL;

pRs.CreateInstance(__uidof(RecordSet));

hr=pRs->Open(Source,Connect,adOpenForwardOnly,adLockOnly,-1);





Any help or references greatly appreciated.  I am new to this and very 

ignorant at this point.



Thanks!

Jeff



Message #2 by "Jeff Haas" <haas_jeff@h...> on Mon, 25 Feb 2002 01:37:15
OK, I bought a book and solved the exception problem by changing the last 

line to:



hr=pRs->Open(Source,pCon,adOpenForwardOnly,adLockOnly,-1);



do I hear anyone crying "wolf"??



Thanks anyway!



Jeff




  Return to Index