在做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字符集改为未设置即可。