关于Query控件的小问题

ntxs 2004-09-20 08:08:01
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Query1 -> Close();
Query1 -> SQL -> Clear();
Query1 -> SQL -> Add("select * from country.db");
Query1 -> SQL -> Add("where populitian >: low and population <: high");
Query1 -> ParamByName("low") -> AsInteger = StrToInt(Edit1 -> Text);
Query1 -> ParamByName("high") -> AsInteger = StrToInt(Edit2 -> Text);
Query1 -> Open();
}

错误:找不到 low 和 high

请问。,怎么解决这个问题呀? 这两个不是表中的属性
...全文
76 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
yoopy 2004-09-20
  • 打赏
  • 举报
回复
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Query1 -> Close();
Query1 -> SQL -> Clear();
Query1 -> SQL -> Add("select * from country.db");
Query1 -> SQL -> Add("where population > :low and population < :high");
Query1 -> ParamByName("low") -> AsInteger = StrToInt(Edit1 -> Text);
Query1 -> ParamByName("high") -> AsInteger = StrToInt(Edit2 -> Text);
Query1 -> Open();
}
因为参数low,high格式错误了,还有字段population 写成了populitian。
ntxs 2004-09-20
  • 打赏
  • 举报
回复
恶心 学个BCB 照着书上都不能运行!
ntxs 2004-09-20
  • 打赏
  • 举报
回复
populitian 本身就是字段啊
sunliwen780502 2004-09-20
  • 打赏
  • 举报
回复
试试下面的.
Query1 -> SQL -> Add("where populitian 字段 >: low and population 字段 <:high");
Query1->ParamByName("low")->Value = Edit1->Text;
Query1->ParamByName("high)->Value = Edit2->Text;

13,825

社区成员

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

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