Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 261
  • Last Modified:

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

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
cytay
Asked:
cytay
  • 11
  • 7
  • 3
  • +3
1 Solution
 
ambienceCommented:
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
 
cytayAuthor Commented:
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
 
AssafLavieCommented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
cytayAuthor Commented:
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
 
ambienceCommented:
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
 
AssafLavieCommented:
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
 
cytayAuthor Commented:
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
 
ambienceCommented:
so where was the error ? CoCreateInstance or QueryInterface ?
0
 
cytayAuthor Commented:
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
 
cytayAuthor Commented:
QueryInterface ! The error message is "No such interface supported". So...
0
 
ambienceCommented:
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
 
ambienceCommented:
use __uuidof(pADOCommand) and then see if it makes any difference ?
0
 
AssafLavieCommented:
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
 
cytayAuthor Commented:
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
 
ambienceCommented:
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
 
cytayAuthor Commented:
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
 
cytayAuthor Commented:
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
 
ambienceCommented:
>>> while doing a remote call
can explain what you mean by remote call ?
0
 
cytayAuthor Commented:
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
 
ShaunWildeCommented:
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
 
cytayAuthor Commented:
Dear ShaunWilde,

    Thanks for the advice. I will test your suggestion next Monday. Happy weekend !
0
 
griesshCommented:
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
 
cytayAuthor Commented:
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
 
ComTechCommented:
I have undeleted this question, refunded the points and will now place it in PAQ.

Regards,
ComTech
CS @ EE
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

  • 11
  • 7
  • 3
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now