What is wrong???
-
Could somebody explain why the following segment of the code is throwing exception in the last line. The error is -2146825069 (0x800A0C93) Remote ADO Error: The operation requested is not allowed in this context. //******************************************* _ConnectionPtr pConnection = NULL ; pConnection.CreateInstance(__uuidof(Connection)); _RecordPtr pRec = NULL ; pRec.CreateInstance(__uuidof(Record)); _bstr_t strConn2("Provider=MSDASQL;Driver={Microsoft Text Driver (*.txt; *.csv)}; DBQ=C:\\Temp" ) ; pConnection->Open(strConn2,"","",NULL); pRec->Open("1.txt", pConnection.GetInterfacePtr(), adModeReadWrite, adFailIfNotExists, adOpenRecordUnspecified, "", "" ) ; //******************************************* What is wrong??? Why I can't open simple text file through Record object??? Bob ( Expert_30@yahoo.com)
-
Could somebody explain why the following segment of the code is throwing exception in the last line. The error is -2146825069 (0x800A0C93) Remote ADO Error: The operation requested is not allowed in this context. //******************************************* _ConnectionPtr pConnection = NULL ; pConnection.CreateInstance(__uuidof(Connection)); _RecordPtr pRec = NULL ; pRec.CreateInstance(__uuidof(Record)); _bstr_t strConn2("Provider=MSDASQL;Driver={Microsoft Text Driver (*.txt; *.csv)}; DBQ=C:\\Temp" ) ; pConnection->Open(strConn2,"","",NULL); pRec->Open("1.txt", pConnection.GetInterfacePtr(), adModeReadWrite, adFailIfNotExists, adOpenRecordUnspecified, "", "" ) ; //******************************************* What is wrong??? Why I can't open simple text file through Record object??? Bob ( Expert_30@yahoo.com)
Hi Bob, i have done the following and it works: _ConnectionPtr pConnection = NULL ; pConnection.CreateInstance(__uuidof(Connection)); _RecordsetPtr pRec = NULL ; pRec.CreateInstance(__uuidof(Recordset)); _bstr_t strConn2("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\\Northwind.mdb") ; pConnection->Open(strConn2,"","",NULL); pRec->Open("SELECT * FROM [Text;Database=c:\\Temp;HDR=YES;FMT=Delimited].[1.txt]", pConnection.GetInterfacePtr(), adOpenStatic, adLockReadOnly, adCmdText); int nCount = pRec->GetRecordCount(); The data: "Praefix";"Trennung" "acco";5 "asso";5 "comm";5 "comp";5 "conc";5 "conf";5