关于“Grid index out of range”的问题

aloneone 2004-04-26 12:27:26
我的程序
1)所用控件
TDBGrid *DBGrid1;
TDBNavigator *DBNavigator1;
TDataSource *DSSQL;
TQuery* Query1;
2)控年设置
DSSQL->DataSet = Query1;
DBNavigator1->DataSource = DSSQL;
DBGrid1->DataSource = DSSQL;

3)出错的情况
3-1) 第一次执行
{
Query1->Close();
Query1->SQL->Clear();
Query1->SQL->Add("select * from aa where qs<"04018");
Query1->Open():
}
然后点击DBNavigator1控件的“Last”按钮,程序正常
3-2)第二次执行
{
Query1->Close();
Query1->SQL->Clear();
Query1->SQL->Add("select * from aa where qs<"04016");
Query1->Open():
}
然后点击DBNavigator1控件的“Last”按钮,程序报“Grid index out of range”错. 点警告框的“确定”按钮后,进入C++Builder的调试状态,不作任何变动,直接
“RUN”按钮,回到程序运行状态,再按DBNavigator1控件的“Last”按钮,程序又正常。
以后每再次重新用SQL查询后,想到数据集的最后一条记录(用语句Query1->Last();也一样),非要出次错,才会正常,不知是何道理,不知有何对策,我估计是DBGrid1的设置有误,但不知具体原因。
请赐教,
为感!!


...全文
516 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
aloneone 2004-06-12
  • 打赏
  • 举报
回复
可能是病毒的问题
aloneone 2004-05-08
  • 打赏
  • 举报
回复
不是这个错,是我的笔误,实为:
Query1->SQL->Add("select * from aa where qs<\"04016\"");
aloneone 2004-05-08
  • 打赏
  • 举报
回复
唉不是语句的问题,改成这梓还是会有错
Query1->SQL->Add("select * from aa")
不知是不是BUG
stonewater 2004-05-08
  • 打赏
  • 举报
回复
这个不对吧
Query1->SQL->Add("select * from aa where qs<\"04016\"");
应为
Query1->SQL->Add("select * from aa where qs<'04016'");
lihongxing2002 2004-04-26
  • 打赏
  • 举报
回复
网格控件设置成只读的
lihongxing2002 2004-04-26
  • 打赏
  • 举报
回复
Query1->SQL->Add("select * from aa where qs<"04016");
这一句有错啊。
改成
Query1->SQL->Add("select * from aa where qs < 04016");

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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