ATL Server / ADO don't work together 
Author Message
 ATL Server / ADO don't work together

Hi,

I have been trying to access a mySQL database using MS ADO
(msado15.dll) and am having trouble connecting to the database (or at
least, so it seems)

The funny part is that I have a test case (in CppUnit) that uses
_exactly_ the same code, and it works just fine:

HRESULT hr = S_OK;  
#import "..../msado.dll"  
// bit to tidy up the smart-pointer names  
Recordset   rs("ADODB.Recordset");  
CString tmp("SELECT * FROM user");  
rs->Open(tmp.AllocSysString(), _T("DSN=mydsnname"),
         MSADO::adOpenStatic,
         MSADO::adLockOptimistic, MSADO::adCmdText);

It fails on the rs->Open call returning E_FAIL within ATL Server, but
not within a win32 console app

Any ideas?

Frustratedly,
Andrew Matthews



Tue, 01 Mar 2005 16:27:50 GMT  
 ATL Server / ADO don't work together
Andrew

I would try something like this in an ATL server:

/* *********************** */
#import "C:\program files\common files\system\ado\msado25.tlb"
...
ADODB::_RecordsetPtr  rs;
rs.CreateInstance(__uuidof(Recordset));
_bstr_t strSql(L"Select * from User");
_bstr_t strCnxt(L"DSN_MyName");
rs->Open(strSql,strCnxt,ADODB::adOpenStatic,ADODB::adLockOptimistic,ADODB::a
dCmdText);
...
rs->Close();
rs.Release();
/* *********************** */

regards
roy fine


Quote:
> Hi,

> I have been trying to access a mySQL database using MS ADO
> (msado15.dll) and am having trouble connecting to the database (or at
> least, so it seems)

> The funny part is that I have a test case (in CppUnit) that uses
> _exactly_ the same code, and it works just fine:

> HRESULT hr = S_OK;
> #import "..../msado.dll"
> // bit to tidy up the smart-pointer names
> Recordset   rs("ADODB.Recordset");
> CString tmp("SELECT * FROM user");
> rs->Open(tmp.AllocSysString(), _T("DSN=mydsnname"),
>          MSADO::adOpenStatic,
>          MSADO::adLockOptimistic, MSADO::adCmdText);

> It fails on the rs->Open call returning E_FAIL within ATL Server, but
> not within a win32 console app

> Any ideas?

> Frustratedly,
> Andrew Matthews



Tue, 01 Mar 2005 21:15:02 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. New SDK and MFC don't work together

2. LoadImage() and GestLastError() don't work together ???

3. New SDK and MFC don't work together

4. ATL service isn't working as normal server anymore

5. Can DAO and ADO work together?

6. ATL: Activex server comp and full control together

7. ACCELERATOR KEYS DON'T WORK WITH OnKeyDown BUT WORK WHEN SPY++ IS RUNNING

8. C++/ATL/ADO - Intellisense not working (statement completion options) not working

9. HREF's to .exe's don't work

10. Don't know why this doesn't work, but

11. Rebar+DialogBar+Tabstops (does'nt work together)

12. Help Wnet API's don't seem to work under WINNT Service Control Manager

 

 
Powered by phpBB® Forum Software