求助:在VC里用MSFlexGrid控件读取SQL Server数据时,总是弹出“Invalid Row Value”

chenjelly 2010-07-20 03:11:27
在VC6.0里 使用MSFlexGrid控件读取SQL Server数据时,总是弹出“Invalid Row Value”,这是怎么回事,如何解决?
...全文
374 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
chenjelly 2010-07-22
  • 打赏
  • 举报
回复
谢谢大家了,我按x_todoo说的,在循环里面加了如下语句:
if(iRow == m_MSGrid.GetRows())
return;

然后就行了,谢谢大家了
chenjelly 2010-07-20
  • 打赏
  • 举报
回复
数据类型没有问题, 我用的是从CRecordset派生的类CReadMeterSet

我把部分代码贴出来:
long COLs=pSet->m_nFields +1;//pSet是CReadMeterSet类型的指针
long ROWs=pSet->GetRecordCount()+1;
m_MSGrid.SetCols(COL);
m_MSGrid.SetRows(ROW);
//读数据到表格中
int iRow=1;
while(!pSet->IsBOF())
{
CString str;

str.Format(" 记录 %ld",pSet->m_Read_Id);
m_MSGrid.SetRow(iRow);
m_MSGrid.SetCol(0);
m_MSGrid.SetText(str);//序号
m_MSGrid.SetCol(1);
m_MSGrid.SetText(pSet->m_Meter_ID);//表号

m_MSGrid.SetCol(2);
m_MSGrid.SetText(pSet->m_Manufacture_ID);

m_MSGrid.SetCol(3);
m_MSGrid.SetText(pSet->m_Meter_Status);//表的工作状态

str.Format("%10.4f",pSet->m_Acc_Heat);
m_MSGrid.SetCol(4)
m_MSGrid.SetText(str);

str.Format("%10.6f",pSet->m_Acc_Flow);
m_MSGrid.SetCol(5);
m_MSGrid.SetText(str);

iRow++;
pSet->MoveNext();
}

谢谢大家了!
x_todoo 2010-07-20
  • 打赏
  • 举报
回复
应该是因为msflexgrid控件的行数小于你设定的行值。在设定当前行时应该判断总的行数是否大于行值。
黑泡泡选手 2010-07-20
  • 打赏
  • 举报
回复
数据类型不匹配吧,调试一下,看看从数据库读出的值是什么呐。。。
饭fan有引力 2010-07-20
  • 打赏
  • 举报
回复
帮顶,没做过

65,186

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧