您的位置:首页 > 其它

VS2005设置Unicode或ASCII字符集问题

2013-03-13 22:04 295 查看



在做VC连接数据库操作时报错如下:



e:\recv-data\inserttodb\pgdb.cpp(213) : error C2664: 'SQLConnectW' : cannot convert parameter 2 from 'SQLCHAR *' to 'SQLWCHAR *'

Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

e:\recv-data\inserttodb\pgdb.cpp(266) : error C2664: 'SQLExecDirectW' : cannot convert parameter 2 from 'SQLCHAR *' to 'SQLWCHAR *'

Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

e:\recv-data\inserttodb\pgdb.cpp(284) : error C2664: 'SQLExecDirectW' : cannot convert parameter 2 from 'SQLCHAR *' to 'SQLWCHAR *'

Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

e:\recv-data\inserttodb\pgdb.cpp(300) : error C2664: 'SQLExecDirectW' : cannot convert parameter 2 from 'SQLCHAR *' to 'SQLWCHAR *'

Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

原因:

VS2005中开发程序时,默认的字符集是Unicode。所以如果程序中使用字符串常量时一定要显示转换为Unicode型,否则编译时报错

解决方法:

项目菜单--项目属性(最后一个)--配置属性--常规--项目默认值--字符集,将使用Unicode字符集改为未设置即可。





内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: