关于C++中遍历表中的字段的有关问题
关于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
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