我用VC做了一个对数据库进行操作的小程序,主要的文件代码就一百来行,方法是用ADO连接ORACLE数据库,由于从来没接触过,参照从网上找的例子,虽然代码基本完成,可现在编译有问题,从而也无法调试是否能连接上库等等操作,此问题已经困扰我一个多星期啦,哪位在这方面有经验的高手帮帮程序员MM我啊,将不胜感激啊,真的很急啊!谢谢啦,拜托啦!

解决方案 »

  1.   

    以下是我在编译过程中出现的错误提示(我不懂):
    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) 中被引用
      

  2.   

    后来经人指点在设置里作了修改,编译正常,可调试时出现如下问题:
    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.
      

  3.   

    全都是链接错误...
    你是不是引用了什么特殊的Lib之类的东西?要是代码不多的话,帖出来看看吧.
      

  4.   

    引用了一些dll,lib,里面也定义了new ,delete 操作符,new,delete操作符重复定义
      

  5.   

    // sms_ps.cpp : 定义控制台应用程序的入口点。
    //#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;
    }
      

  6.   

    setting中的runtime library是怎么样的
      

  7.   

    楼上的,runtime library是multithread,不对吗?你有MSN,我加你
      

  8.   

    to勇敢的心:不行啊,改成那样错afxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in msvcprtd.lib(delop_s.obj)
    nafxcwd.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argv
    nafxcwd.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argc
    nafxcwd.lib(filelist.obj) : error LNK2001: unresolved external symbol __mbctype
    nafxcwd.lib(timecore.obj) : error LNK2001: unresolved external symbol __mbctype
    nafxcwd.lib(apphelp.obj) : error LNK2001: unresolved external symbol __mbctype
    Debug/sms_ps.exe : fatal error LNK1120: 3 unresolved externals误更多啊,
      

  9.   

    或者如果方便的话,请高手留下MSN,希望能在线指导我
      

  10.   

    噢,现在那个问题基本解决啦,代码没变,可现在老是出现“create Instance faile!”,这好像是代码的问题,可我实在检查不出代码哪有问题啊
      

  11.   

    你把这行代码提前hr = ::CoInitialize(NULL);  放到if (FAILED(pConn.CreateInstance("ADODB.Connection")))之前试试。
      

  12.   

    哦,为什么连接不上数据库呀,“not open database!”那上连接字符串中的数据源到底指的是什么啊?我现在是在装ORACLE的服务器上调试的,请各位高手指教啊,我的QQ59955643,希望能得到在线指教,急急急啊