首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

关于C++中遍历表中的字段的有关问题

2012-02-04 
关于C++中遍历表中的字段的问题 for(inti0i counti++){hrfields- Item[i]- get_Name(&bstrColName)

关于C++中遍历表中的字段的问题

for(int   i   =   0;i <count;i++)
{
hr=fields-> Item[i]-> get_Name(&bstrColName);
strcpy(colName,(LPCTSTR)bstrColName);


为什么老是提示如下错误:
error   C2664:   'GetItem '   :   cannot   convert   parameter   1   from   'int '   to   'const   class   _variant_t   & '

请高手指明原因。谢谢。



[解决办法]
作一个类型转换:
strStaffID=(char*)(_bstr_t)(pRS-> GetFields()-> GetItem( "工号 ")-> GetValue());
[解决办法]
GetItem的第一个参数需要是_variant_t 不能传int


你要把传一个_variant_t进去,再把结果转成你要的int形
[解决办法]
for(long i = 0;i <count;i++)
{
hr=fields-> Item[i]-> get_Name(&bstrColName);
strcpy(colName,(LPCTSTR)bstrColName);

把int转换为long

热点排行