Solved

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

Posted on 2001-06-21
24
256 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How can i compile this github project?? 2 97
Syntax Error 2 91
Angular JS Route 3 98
Create a worker thread ( servicing thread) using the Message queue 3 17
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

735 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