cytay
asked on
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.CreateI nstance(__ uuidof(Com mand)));
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.CreateI
ASKER
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 !?
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 !?
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?
To your question: Have you made sure that ADO is installed on both machines; both at the same version?
ASKER
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...
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...
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 ?
Try compiling it on server and copying to client (i mean the other way around), does that work ?
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.
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.
ASKER
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(_uuidofCo mmand),
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(_C ommand),
(void**)&pADOCommand);
if (FAILED(m_lError))
{
m_lError = -1;
m_strError = _T("QueryInterface fail");
return -1;
}
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(_uuidofCo
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(
(void**)&pADOCommand);
if (FAILED(m_lError))
{
m_lError = -1;
m_strError = _T("QueryInterface fail");
return -1;
}
so where was the error ? CoCreateInstance or QueryInterface ?
ASKER
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(_uuidofCo mmand),
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(_C ommand),
(void**)&pADOCommand);
if (FAILED(m_lError))
{
m_lError = -1;
m_strError = _T("QueryInterface fail");
return -1;
}
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(_uuidofCo
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(
(void**)&pADOCommand);
if (FAILED(m_lError))
{
m_lError = -1;
m_strError = _T("QueryInterface fail");
return -1;
}
ASKER
QueryInterface ! The error message is "No such interface supported". So...
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.CreateI nstance(__ uuidof(Com mand)));
can be safely converted to
TESTHR(pADOCommand.CreateI nstance(__ uuidof(pAD OCommand)) );
hr = pADOCommand.CreateInstance
try using this one !!
also as a general practice its better to use object in __uuidof() than its type so
TESTHR(pADOCommand.CreateI
can be safely converted to
TESTHR(pADOCommand.CreateI
use __uuidof(pADOCommand) and then see if it makes any difference ?
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.
I assume then that the problem is with the library installation or something.
Try creating a Command object using VB on the problematic machine.
ASKER
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.
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.
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.CreateI nstance(__ uuidof(pAD OCommand)) );
when i had wanted you to do the following
m_lError = pIUnknown->QueryInterface( _uuidof(pA DOCommand) ,
(void**)&pADOCommand);
I am extremely sorry for this causalness.
But there appears to be a problem with installation.
My fault i told u to do this
TESTHR(pADOCommand.CreateI
when i had wanted you to do the following
m_lError = pIUnknown->QueryInterface(
(void**)&pADOCommand);
I am extremely sorry for this causalness.
But there appears to be a problem with installation.
ASKER
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.
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.
ASKER
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...
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...
>>> while doing a remote call
can explain what you mean by remote call ?
can explain what you mean by remote call ?
ASKER
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.
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.
instead of using _uuidof try using the ProgId - ADODB.Command -
TESTHR(pADOCommand.CreateI nstance("A DODB.Comma nd"));
I am assuming you are using _com_ptr_t
TESTHR(pADOCommand.CreateI
I am assuming you are using _com_ptr_t
ASKER
Dear ShaunWilde,
Thanks for the advice. I will test your suggestion next Monday. Happy weekend !
Thanks for the advice. I will test your suggestion next Monday. Happy weekend !
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: https://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
The link to the Community Support area is: https://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
ASKER
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)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>>> 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 ?