
"Pure Virtual Function Call"
Try to do like this:
STDMETHODIMP CeutTest::getConnection(BSTR ConnectString, _Connection **conn)
{
// TODO: Add your implementation code here
char *constring="";
constring = (char *)ConnectString;
HRESULT hr = S_OK;
if (strlen(constring) != 0)
{
_ConnectionPtr a;
a.CreateInstance(__uuidof(Connection));
a->Open(_T(ConnectString),_T(""),_T(""),-1);
hr = a.QueryInterface(__uuidof(_connection),(void **)Conn)
}
else
{
hr = E_INVALIDARG;
//Don't try to set Conn = NULL directly, return a hr with a error
information
// is enough.
}
return hr;
}
I wish it will help u.
Quote:
> Thanks for your tip on variant.
> But I am not able to solve the "pure virtual function call error"
> In fact I get this error when I try to return a connection object.
> This is the code i entered
> STDMETHODIMP CeutTest::getConnection(BSTR ConnectString, _Connection
**conn)
> {
> // TODO: Add your implementation code here
> char *constring="";
> constring = (char *)ConnectString;
> if (strlen(constring) != 0)
> {
> _ConnectionPtr a;
> a.CreateInstance(__uuidof(Connection));
> a->Open(_T(ConnectString),_T(""),_T(""),-1);
> *conn.CreateInstance(__uuidof(Connection));
> *conn = a;
> }
> else
> {
> *conn = NULL;
> }
> return S_OK;
> }
> Can anyone tell me what is this problem.
> Thanks
> Sujatha
> > This usually occurs if you have stale typelib getting linked..
Basically,
> VB
> > is attempting to make a call to a non existant method( caused either due
> to
> > invalid id() list in IDL or having a bad typelib to link to). Try to
repro
> > this problem with a simple C++ client.. See if the call actually comes
> > through.
> > To return a variant , Just declare your method to have a [out,retval]
> > VARIANT*..
> > And stuff that VARIANT.vt with the right type (VT_DISPATCH, or VT_BSTR)
> and
> > fill the right union val( .bstrVal or pDispVal (??)).
> > --
> > Girish Bharadwaj
> > > Hi,
> > > I am trying to return a connection information from my com dll to a VB
> > > client. The connection is established and the connectstring is
> displayed
> > in
> > > the VB client after which it gives me a runtime error "Pure Virtual
> > function
> > > call". I am not able to identify this problem. can anyoone help me
> out.
> > > Also can anyone give me some tips on how to return variant types to my
> > > client bcos i have to return a connection info if the connection is
> > > established , else a connectstring has to be sent to the client.
> > > Thanks in advance