to:酷狗 我不懂线程,所以我也不知道错误在哪儿,我加了你的MSN,等你上线听从指教! to:彬彬 我按照你的方法改了之后,编译正常,调试中的错误提示如下: Linking... nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in libcpmtd.lib(delop.obj) LINK : warning LNK4098: defaultlib "LIBCMT" conflicts with use of other libs; use /NODEFAULTLIB:library Debug/sms_ps.exe : fatal error LNK1169: one or more multiply defined symbols found Error executing link.exe.
pConn->Open(_bstr_t(strSRC),"myid","mypassword",-1); strSQL="SELECT * FROM PLAT_CMPP_MT_TABLS"; if(pConn->Execute(_bstr_t(strSQL),&vtOptional,-1)!=NULL) { //判断是否是网上用户 strSQL="SELECT * FROM FROM PLAT_CMPP_MT_TABLS WHERE DESTTERMID IN (SELECT USERNICK FROM FROM PLAT_WWWUSER_INFOR )"; pPtr=pConn->Execute(_bstr_t(strSQL),&vtOptional,-1); CString temp; if(pPtr==NULL) temp="PLAT_CMPP_MT_TABLE";//手机用户发送消息表 else temp="PLAT_CMPP_MT_WWWUSER";//网上用户发送消息表 str_SQL="SELECT * FROM "+temp; ps=pConn->Execute(_bstr_t(str_SQL),&vtOptional,-1); while (!pPtr->adoEOF) {
AfxOleInit();//初始化COM库
HRESULT hr;
try
{
hr = m_pConnection.CreateInstance(__uuidof(Connection));///创建Connection对象
//m_pConn.CreateInstance(__uuidof(Connection));
if(SUCCEEDED(hr))
{
m_pConnection->ConnectionTimeout=10;///设置超时时间为10秒
hr =m_pConnection->Open("Provider=oraoledb.oracle;Data Source=oralz.oracle;User ID=lztljsms;Password=jgl;PLSQLRSet=1","","",adModeUnknown);
///连接数据库
}
}
catch(_com_error e)///捕捉异常
{
CString temp;
temp.Format("连接数据库错误信息:%s",e.ErrorMessage());
::MessageBox(NULL,temp,"提示信息",NULL);
return false;
}
注意:Data Source=oralz.oracle;为ORACLE服务名,而不是数据库名
sms_ps error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) 已经在 libcpd.lib(newop.obj) 中定义sms_ps error LNK2019: 无法解析的外部符号 __beginthreadex ,该符号在函数 "public: int __thiscall CWinThread::CreateThread(unsigned long,unsigned int,struct _SECURITY_ATTRIBUTES *)" (?CreateThread@CWinThread@@QAEHKIPAU_SECURITY_ATTRIBUTES@@@Z) 中被引用sms_ps error LNK2019: 无法解析的外部符号 __endthreadex ,该符号在函数 "void __stdcall AfxEndThread(unsigned int,int)" (?AfxEndThread@@YGXIH@Z) 中被引用
参考:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/vcerrlinkertoolserrorlnk2019.asp
可能的情况是函数拼写错误,参数不符合,或者调用格式不统一。
检查你的线程函数。
Project->Setting->link->input, 在ignord lib一栏中填入libcpd.libProject->Setting->C++->code generation, 将runtime library改为multithread
我不懂线程,所以我也不知道错误在哪儿,我加了你的MSN,等你上线听从指教!
to:彬彬
我按照你的方法改了之后,编译正常,调试中的错误提示如下:
Linking...
nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in libcpmtd.lib(delop.obj)
LINK : warning LNK4098: defaultlib "LIBCMT" conflicts with use of other libs; use /NODEFAULTLIB:library
Debug/sms_ps.exe : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.
只要改写这句就对了;
//#include "stdafx.h"
#include "sms_ps.h"
#include "process.h"#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// 唯一的应用程序对象
CWinApp theApp;int _tmain(int argc, _TCHAR* argv[])
{
int n = 0; // 初始化 MFC 并在失败时显示错误
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: 更改错误代码以符合您的需要
_tprintf(_T("致命错误: MFC 初始化失败\n"));
n = 1;
return 0;
}
else
{
// TODO: 在此处为应用程序的行为编写代码。
}
_ConnectionPtr pConn;
if (FAILED(pConn.CreateInstance("ADODB.Connection")))
{
AfxMessageBox("Create Instance failed!");
return 0;
} _RecordsetPtr pPtr;
pPtr.CreateInstance(_uuidof(Recordset));
_RecordsetPtr ps;
ps.CreateInstance(_uuidof(Recordset)); CString strSRC;
CString strSQL;
CString str_SQL;
HRESULT hr; hr = ::CoInitialize(NULL);
if(hr != S_OK)
{
return 0;
}
strSRC="Provider=MSDAORA.1;Data Source=mydb;Password=mypassword;User ID=myid";
COleVariant vtOptional((long)DISP_E_PARAMNOTFOUND,VT_ERROR);
_variant_t varSRC(strSRC);
_variant_t varSQL(strSQL);
//_variant_t varSQL(str_SQL);
_bstr_t bstrSRC(strSRC);
try
{
//while(1)
//
pConn->Open(_bstr_t(strSRC),"myid","mypassword",-1);
strSQL="SELECT * FROM PLAT_CMPP_MT_TABLS";
if(pConn->Execute(_bstr_t(strSQL),&vtOptional,-1)!=NULL)
{
//判断是否是网上用户
strSQL="SELECT * FROM FROM PLAT_CMPP_MT_TABLS WHERE DESTTERMID IN (SELECT USERNICK FROM FROM PLAT_WWWUSER_INFOR )";
pPtr=pConn->Execute(_bstr_t(strSQL),&vtOptional,-1);
CString temp;
if(pPtr==NULL)
temp="PLAT_CMPP_MT_TABLE";//手机用户发送消息表
else
temp="PLAT_CMPP_MT_WWWUSER";//网上用户发送消息表
str_SQL="SELECT * FROM "+temp;
ps=pConn->Execute(_bstr_t(str_SQL),&vtOptional,-1);
while (!pPtr->adoEOF)
{
ps->AddNew();//手机(网上)用户消息表添加新记录
ps->PutCollect("ID",long(111)); //ps->PutCollect("ID",_variant_t(int(ps->GetMaxRecords())+1));
ps->PutCollect("SRCTERMID",pPtr->GetCollect("SRCTERMID"));
ps->PutCollect("DESTTERMID",pPtr->GetCollect("DESTTERMID"));
ps->PutCollect("FEETERMID",pPtr->GetCollect("FEETERMID"));
ps->PutCollect("MSGCONTENT",pPtr->GetCollect("MSGCONTENT"));
ps->PutCollect("FEECODE",pPtr->GetCollect("FEECODE"));
ps->PutCollect("FEETPE",pPtr->GetCollect("FEETYPE"));
ps->PutCollect("SERVICEID",pPtr->GetCollect("SERVICEID"));
ps->PutCollect("COMPANY",pPtr->GetCollect("COMPANY"));
ps->PutCollect("NEEDREPLY",pPtr->GetCollect("NEEDREPLY"));
ps->PutCollect("MSGFORMAT",pPtr->GetCollect("MSGFORMAT"));
ps->PutCollect("POSITIONCODE",pPtr->GetCollect("POSITIONCODE"));
ps->PutCollect("DATETIME",pPtr->GetCollect("DATETIME"));
ps->PutCollect("LINKID",pPtr->GetCollect("LINKID"));
if(temp=="PLAT_CMPP_MT_WWWUSER")
ps->PutCollect("ISNEW","y");
ps->Update();
pPtr->MoveNext();
}
//删除已写入的原表记录
pConn->Execute(_bstr_t("DELETE FROM PLAT_CMPP_MT_TABLS"),&vtOptional,-1);
ps->Close();
pPtr->Close();
}
// }
}
catch(_com_error e)
{
CString errormessage;
errormessage.Format("not open database \r\n错误信息:%s",e.ErrorMessage());
printf(errormessage);
}
pConn->Close();
::CoUninitialize();
return 1;
}主要的源代码
if(hr != S_OK)
{
return 0;
}