Open Excel file,Error

_ConnectionPtr m_adoConn;
_RecordsetPtr m_adoRec;
::CoInitialize(NULL);
m_adoConn.CreateInstance(__uuidof(Connection));
m_adoConn->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\1.xls;Extended Properties=Excel 8.0;IMEX=1;","","",adModeUnknown);


stop this function:
inline HRESULT Connection15::Open ( _bstr_t ConnectionString, _bstr_t UserID, _bstr_t Password, long Options ) {
HRESULT _hr = raw_Open(ConnectionString, UserID, Password, Options);
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
return _hr;
}

why error
thank:)

I don't really know anything about that raw_open() function, but from this vb example the parameters are supposed to be of type _variant_t, not BSTR.

Hi,

Maybe you should check your excel file to see if it corrupts. If so, you may try Advanced Excel Repair This tool is rather useful in salvaging damaged Excel xls files.

Alan

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.