MFC in the call statement:
StrSQL. The Format (" update wageinfo set wage=% lf, date='% s' where id=' % s' ", m_nWage, strDate, m_strID);
Int RVSQL=dboperafunc (strSQL);
If (RVSQL!=0)
DBOPERA_ERROR;
Definition of dboperafunc functions in the DLL:
DBOPERADLL_API int dboperafunc (const CString& SQL)
{
Try {
_ConnectionPtr pConnection;
Retrieves the hr=pConnection. CreateInstance (" ADODB. Connection ");//create a Connection object
If (SUCCEEDED (hr))
Hr=pConnection - & gt; Open (" driver={SQL Server}; Server=(local); The DATABASE=HMSys;" , ""," ", adModeUnknown);
//_ConnectionPtr m_pConnection=openDb ();
PConnection - & gt; Execute (SQL (_bstr_t), NULL, adCmdText);
return 0;
}
Catch _com_error (e)
{
Cstrings strComError;
StrComError. Format (" wrong number: 08 lx \ % n error message: % s \ n error source: % s \ n error description: % s ",
E.E rror (),//error Numbers
E.E rrorMessage (),//the error information
(LPCSTR) e.S ource (),//error source
(LPCSTR) e.D escription ());//error description
: : MessageBox (NULL, strComError, "error", MB_ICONEXCLAMATION);
Return e.E rror ();
}
}
DLL can be compiled, there is. Lib and. DLL files, MFC attributes have the correct link to the DLL generated. Lib files, but at the time of compilation of MFC will prompt the following error:
Error LNK2019 cannot resolve the external symbol "__declspec (dllimport) int __cdecl dboperafunc (class ATL: : CStringT
The man tips do something wrong??????? Thank you
CodePudding user response:
1. In C/C + + DLL corresponding directory contains header files, libraries directory contains the DLL file2. The DLL is added in the linker - "input option corresponding lib file
3. Generate DLL character set and call DLL exe unified character set?
CodePudding user response:
CoInitialize(NULL);
//...
CoUninitialize ();
?
CodePudding user response: