ATL COM Connectionpoint Error
Hi,
I have written a code on com connection point to connect to the database and insert the given values into the table.I have written the below code in the insert button handler.But , I am getting the erroes like
'_Connection' : undeclared identifier
'CComPtr' : use of class template requires template argument list
CComPtr' : no appropriate default constructor available
LRESULT OnInsert(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
BSTR str;
BSTR str1;
GetDlgItemText(IDC_EDIT1,str);
GetDlgItemText(IDC_EDIT2,str1);
CoInitialize(NULL);
CComPtr<_Connection>pCon;
pCon.CoCreateInstance(__uuidof(Connection));
pCon->Open("MYNEWDATASOURCE","","",-1);
CComPtr<_Recordset>pRec;
pRec.CoCreateInstance(__uuidof(Recordset));
char str2[255];
sprinf(str2,"insert into NEWTABLENAME (SNO,SNAME) values (&s,&s)",str1,str);
_vriant_t vQuery;
vQuery.SetString(str2);
pRec->Open(vQuery,(CComVariant)pCon,adOpenStatic,adLockReadOnly,adCmdUnknown);
return 0;
}
If some one knows help me.
Re: COM Connectionpoint Error
I think you have to add some includes to your sourcefiles. You have to find out if _ComPtr is declared in one of the following headerfiles: atlbase.h, atlcom.h. Otherwise try a google or msdn search on 'ATL source code files'. Hope this helps.