VC FlexGrid控件无法插入数据,该怎么处理

VC FlexGrid控件无法插入数据
VC FlexGrid控件无法插入数据,报 SubScript out of range 错误, put_Text()的时候出错, 但是我从数据库中正确获取了数据,而且传入的参数,数据也是对的,就是无法插入数据。

请大家帮帮忙 看看 谢谢 !!!!!!!!!!!!!


代码如下:


::CoInitialize(NULL); //初始化COM环境
m_pConnection=NULL;
m_pConnection.CreateInstance(__uuidof(Connection)); //连接对象实例化
m_pConnection->ConnectionString="uid=admin;pwd=111;DRIVER=\
{Microsoft Access Driver (*.mdb)};DBQ=mrsoft.mdb;"; //设置连接字符串
m_pConnection->Open(L"",L"",L"",adCmdUnspecified);

CString head = "编号 | 名称 | 数量";
m_ctrlFGridThree.put_FormatString(head);

m_pRecordset=m_pConnection->Execute((_bstr_t)("select * from info"),
NULL,adCmdText); 

m_ctrlFGridThree.put_Cols(3);//设置列数
long RecordNum = 4;
m_ctrlFGridThree.put_Rows(RecordNum + 1);

m_ctrlFGridThree.put_CellAlignment(6);//对齐方式flexAlignRightTop
  CRect rect;
  m_ctrlFGridThree.GetWindowRect(&rect);
  m_ctrlFGridThree.put_ColWidth(0, rect.Width()*2); 
  m_ctrlFGridThree.put_ColWidth(1, rect.Width()*4);
  m_ctrlFGridThree.put_ColWidth(2, rect.Width()*2);

m_ctrlFGridThree.Clear();
m_ctrlFGridThree.Refresh();

m_pRecordset->MoveFirst();//移动记录游标到第一条记录
for(long CurRow = 1; CurRow <= RecordNum ; CurRow++)//初始化grid控件显示。

CString str;
int CurCol = 0;
_variant_t vstr;
m_ctrlFGridThree.put_Rows(CurRow);
m_ctrlFGridThree.put_Cols(CurCol);
vstr = m_pRecordset->GetCollect("index");
str = (LPCSTR)_bstr_t(vstr);
m_ctrlFGridThree.put_Text(str); [b][/b]//就是这报错,,无法插入数据

m_ctrlFGridThree.put_Cols(++CurCol);
vstr = m_pRecordset->GetCollect("name");
str = (LPCSTR)_bstr_t(vstr);
m_ctrlFGridThree.put_Text(str);

m_ctrlFGridThree.put_Cols(++CurCol);
vstr = m_pRecordset->GetCollect("Num");
str = (LPCSTR)_bstr_t(vstr);

m_pRecordset->MoveNext();
}

------解决方案--------------------
这有个例子
看看能不能参考一下
http://download.csdn.net/download/pingping45/2508558