解决error C2065:"..."未声明的标识符,C2065:语法错误: 标识符“...”

网狐项目工程中有时候会出现 C2065错误,一般情况下有可能是 项目工程配置出错



只需要选择 Visual Studio 2013(v120)  就可以了

error C2065: “_ConnectionPtr”: 未声明标识符

01-16

莫名其妙啊,以前从来没遇到这问题,今天终于碰到了,大家看看我哪里出问题了rn1、在stdafx.h 最后包含rn[code=c]rn#import "c:\program files\common files\system\ado\msado15.dll" named_guids rename_namespace("ADOCG") rename("EOF", "adoEOF") rename("BOF","adoBOF")rnusing namespace ADOCGrn[/code]rn2、然后我自定义了一个类函数rn[code=c]rnvoid CIOCPModel::WriteIntoDataBase(CString str1, CString str2)rn//str1、str2是传进来的字符串rnrn CoInitialize(NULL);rn _ConnectionPtr m_pConnection; //连接对象指针rn tryrn rn m_pConnection.CreateInstance("ADODB.Connection"); //创建连接对象实例rn bstr_t strConnect="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Modbus_TCP.mdb;Persist Security Info=False";rn m_pConnection->Open(strConnect,"","",adModeUnknown); //打开数据库rn rn catch (_com_error e) //捕捉错误rn rn AfxMessageBox(e.Description()); rn return;//弹出错误rn rn tryrn rn _bstr_t sql = _T("INSERT INTO message (时间,内容) VALUES (str1,str2)");rn m_pConnection->Execute(sql,NULL,adCmdText);rn rn catch (_com_error e)rn rn AfxMessageBox(e.Description()); rn return;//弹出错误rn rnrn m_pConnection->Close();rn CoUninitialize();rnrn[/code]rn3、结果就悲剧了,大家帮我看看是漏了什么还是。。。rn[code=text]rn错误信息rn错误 7 error C2065: “_ConnectionPtr”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 814 PiggyIOCPServerrn错误 8 error C2146: 语法错误 : 缺少“;”(在标识符“m_pConnection”的前面) c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 814 PiggyIOCPServerrn错误 9 error C2065: “m_pConnection”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 814 PiggyIOCPServerrn错误 10 error C2065: “m_pConnection”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 817 PiggyIOCPServerrn错误 11 error C2228: “.CreateInstance”的左边必须有类/结构/联合 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 817 PiggyIOCPServerrn错误 12 error C2065: “bstr_t”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 818 PiggyIOCPServerrn错误 13 error C2146: 语法错误 : 缺少“;”(在标识符“strConnect”的前面) c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 818 PiggyIOCPServerrn错误 14 error C2065: “strConnect”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 818 PiggyIOCPServerrn错误 15 error C2065: “m_pConnection”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 819 PiggyIOCPServerrn错误 16 error C2227: “->Open”的左边必须指向类/结构/联合/泛型类型 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 819 PiggyIOCPServerrn错误 17 error C2065: “strConnect”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 819 PiggyIOCPServerrn错误 18 error C2065: “adModeUnknown”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 819 PiggyIOCPServerrn错误 19 error C2061: 语法错误 : 标识符“_com_error” c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 821 PiggyIOCPServerrn错误 20 error C2310: catch 处理程序必须指定一种类型 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 821 PiggyIOCPServerrn错误 21 error C2065: “e”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 823 PiggyIOCPServerrn错误 22 error C2228: “.Description”的左边必须有类/结构/联合 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 823 PiggyIOCPServerrn错误 23 error C2317: 在行“816”上开始的“try”块没有 catch 处理程序 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 826 PiggyIOCPServerrn错误 24 error C2065: “_bstr_t”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 828 PiggyIOCPServerrn错误 25 error C2146: 语法错误 : 缺少“;”(在标识符“sql”的前面) c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 828 PiggyIOCPServerrn错误 26 error C2065: “sql”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 828 PiggyIOCPServerrn错误 27 error C2065: “m_pConnection”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 829 PiggyIOCPServerrn错误 28 error C2227: “->Execute”的左边必须指向类/结构/联合/泛型类型 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 829 PiggyIOCPServerrn错误 29 error C2065: “sql”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 829 PiggyIOCPServerrn错误 30 error C2065: “adCmdText”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 829 PiggyIOCPServerrn错误 31 error C2061: 语法错误 : 标识符“_com_error” c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 831 PiggyIOCPServerrn错误 32 error C2310: catch 处理程序必须指定一种类型 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 831 PiggyIOCPServerrn错误 33 error C2065: “e”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 833 PiggyIOCPServerrn错误 34 error C2228: “.Description”的左边必须有类/结构/联合 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 833 PiggyIOCPServerrn错误 35 error C2317: 在行“827”上开始的“try”块没有 catch 处理程序 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 837 PiggyIOCPServerrn错误 36 error C2065: “m_pConnection”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 837 PiggyIOCPServerrn错误 37 error C2227: “->Close”的左边必须指向类/结构/联合/泛型类型 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 837 PiggyIOCPServerrnrn[/code]

没有更多推荐了,返回首页

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试