Solved

Client compiled COM dll can not initialzed ADO Command at server side !

Posted on 2001-06-21
24
252 Views
Last Modified: 2013-12-14
Dear all,

    Lately I'm developing data access tier in COM way. I face a problem where the COM dll generated at my PC can not initialize ADO Command at server. The dll has been registered at server before I use its service. The error message is "No such interface supported.".

    But if I compile the codes at server side, the dll can initialize ADO Command. Can anyone out there tell me a way to solve this ASAP !? Thanks in advance !

The way I initialize ADO Command is as below...
_CommandPtr pADOCommand = NULL;
TESTHR(pADOCommand.CreateInstance(__uuidof(Command)));
0
Comment
Question by:cytay
  • 11
  • 7
  • 3
  • +3
24 Comments
 
LVL 22

Expert Comment

by:ambience
ID: 6217015
can explain a bit more ? . if you compile it at server it works fine and if at client then it wont ? , the dll is always registered at the server ?

>>> the COM dll generated at my PC can not initialize ADO Command at server.

what do u mean by ADO command at server , are you tryint to access datasource at server using ADO ?

>>> dll has been registered at server before I use
its service.

How are u using its services ?
0
 

Author Comment

by:cytay
ID: 6217141
Dear ambience,

Thanks for your immediate reply. I really appreciate it.

For your first question...
I compiled codes at my PC, then I copied the generated dlls to server for registration. I used Component Service to register the dlls. The ADO Command initialization at server failed.
I copied codes to server from my PC, then I compiled codes at server. I did the same way registration as the previous case. The ADO Command initialization at server worked.

For your second and third questions...
My data access tier scenario is The COM dlls will use ADO components' services to do the data operations on database server. The COM dlls and ADO components should be placed at the same server, but the database server can be any server that installed MS SQL Server. Understand !?
0
 
LVL 4

Expert Comment

by:AssafLavie
ID: 6217163
First of all, you don't have to initialie smart pointers to NULL.
To your question: Have you made sure that ADO is installed on both machines; both at the same version?
0
 

Author Comment

by:cytay
ID: 6217181
Dear AssafLavie,

Thanks for the prompt response. Setting the smart pointer or any pointer to NULL is my habit. Will this approach cause the problem ? Meanwhile, I installed the same latest MDAC SDK at my PC and server. Its version is 2.6.

So...
0
 
LVL 22

Expert Comment

by:ambience
ID: 6217219
this is strange , the only problem i could have expected was version in-consistencies , you have the same SDK and ADO dlls so that is realy strange..

Try compiling it on server and copying to client (i mean the other way around), does that work ?
0
 
LVL 4

Expert Comment

by:AssafLavie
ID: 6217244
Setting the smart pointer to NULL is redundant, but it won't cause any errors.
Try breaking the _CommandPtr instanciation down to it's lower level APIs.
Try calling CoCreateInstace and getting an IUnknown *.
Then try to QI it to _Command.
Tell us which function fails and what error code it returns.
0
 

Author Comment

by:cytay
ID: 6217422
Dear ambience & AssafLavie,

I have tried the other way of testing. It works fine. Is it because I compiled the codes at server ?

Then I have tried the way suggested by AssafLavie. It failed. The following is the code I wrote for testing...
IUnknown* pIUnknown = NULL;
m_lError = CoCreateInstance(_uuidofCommand),
                            NULL,
                            CLSCTX_ALL,
                            _uuidof(IUnknown),
                            (void**)&pIUnknown);

if (FAILED(m_lError))
{
    m_lError = -1;
    m_strError = _T("CoCreateInstance fail");
    return -1;
}

m_lError = pIUnknown->QueryInterface(_uuidof(_Command),
                                     (void**)&pADOCommand);

if (FAILED(m_lError))
{
    m_lError = -1;
    m_strError = _T("QueryInterface fail");
    return -1;
}
0
 
LVL 22

Expert Comment

by:ambience
ID: 6217454
so where was the error ? CoCreateInstance or QueryInterface ?
0
 

Author Comment

by:cytay
ID: 6217455
Dear ambience & AssafLavie,

I have tried the other way of testing. It works fine. Is it because I compiled the codes at server ?

Then I have tried the way suggested by AssafLavie. It failed. The following is the code I wrote for testing...
IUnknown* pIUnknown = NULL;
m_lError = CoCreateInstance(_uuidofCommand),
                            NULL,
                            CLSCTX_ALL,
                            _uuidof(IUnknown),
                            (void**)&pIUnknown);

if (FAILED(m_lError))
{
    m_lError = -1;
    m_strError = _T("CoCreateInstance fail");
    return -1;
}

m_lError = pIUnknown->QueryInterface(_uuidof(_Command),
                                     (void**)&pADOCommand);

if (FAILED(m_lError))
{
    m_lError = -1;
    m_strError = _T("QueryInterface fail");
    return -1;
}
0
 

Author Comment

by:cytay
ID: 6217462
QueryInterface ! The error message is "No such interface supported". So...
0
 
LVL 22

Expert Comment

by:ambience
ID: 6217496
First an alternative
hr = pADOCommand.CreateInstance(_T("ADODB.Command"));
try using this one !!

also as a general practice its better to use object in __uuidof() than its type so

TESTHR(pADOCommand.CreateInstance(__uuidof(Command)));

can be safely converted to

TESTHR(pADOCommand.CreateInstance(__uuidof(pADOCommand)));

0
 
LVL 22

Expert Comment

by:ambience
ID: 6217501
use __uuidof(pADOCommand) and then see if it makes any difference ?
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 4

Expert Comment

by:AssafLavie
ID: 6217524
Teh code is obviuosley fine the way it is - since it works on another machine, right?
I assume then that the problem is with the library installation or something.
Try creating a Command object using VB on the problematic machine.
0
 

Author Comment

by:cytay
ID: 6217583
Dear ambience,

For the first approach, the error message is "No such interface supported.". And the second approach's result is still fail. Its error message is "Class not registered.".

I felt so sorry to trouble and disappoint you here.
0
 
LVL 22

Expert Comment

by:ambience
ID: 6217632
No such interface was expected ofcourse since __uuidof has same effect with type and object , and class not registered is also fairly obvious.

My fault i told u to do this

TESTHR(pADOCommand.CreateInstance(__uuidof(pADOCommand)));

when i had wanted you to do the following

m_lError = pIUnknown->QueryInterface(_uuidof(pADOCommand),
                                    (void**)&pADOCommand);

I am extremely sorry for this causalness.
But there appears to be a problem with installation.



0
 

Author Comment

by:cytay
ID: 6217645
Dear ambience,

For the first approach, the error message is "No such interface supported.". And the second approach's result is still fail. Its error message is "Class not registered.".

I felt so sorry to trouble and disappoint you here.
0
 

Author Comment

by:cytay
ID: 6217688
Dear all,

I have tried the testing on VB at local PC. The ADO Command works well. For the suggestion made by ambience, the same error happened as previous one, "No such interface supported.". For your information, this error happened while doing a remote call, and the dll which stored at server is generated at local pc. Therefore...
0
 
LVL 22

Expert Comment

by:ambience
ID: 6217717
>>> while doing a remote call
can explain what you mean by remote call ?
0
 

Author Comment

by:cytay
ID: 6217724
Dear ambience,

A remote call means... The COM dlls are run at server, my program which executed from my PC to get the services from the dlls. It works like DCOM.
0
 
LVL 9

Expert Comment

by:ShaunWilde
ID: 6218014
instead of using _uuidof try using the ProgId - ADODB.Command -

TESTHR(pADOCommand.CreateInstance("ADODB.Command"));

I am assuming you are using _com_ptr_t


0
 

Author Comment

by:cytay
ID: 6219326
Dear ShaunWilde,

    Thanks for the advice. I will test your suggestion next Monday. Happy weekend !
0
 
LVL 11

Expert Comment

by:griessh
ID: 6820010
I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. Unless there is objection or further activity,  I will suggest to refund the points and PAQ at zero points since nobody had a solution for you.

The link to the Community Support area is: http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner

0
 

Author Comment

by:cytay
ID: 6821166
This question has been here for quite some times, but no one can give me a satisfied answer. Therefore I have to delete this question. Before doing so, I would like to thank those who assisted me. :o)
0
 

Accepted Solution

by:
ComTech earned 0 total points
ID: 6837672
I have undeleted this question, refunded the points and will now place it in PAQ.

Regards,
ComTech
CS @ EE
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now