首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

adoquery 的记录集有关问题

2012-04-04 
adoquery 的记录集问题?qrytemp.SQL.Add( selectcount(*)fromtroomwhereclassname +QuotedStr(TreeView1.

adoquery 的记录集问题?


  qrytemp.SQL.Add( 'select   count(*)   from   troom   where   classname= '+   QuotedStr(TreeView1.Selected.Text));
    qrytemp.Open;
    //Edit1.Text:=   IntToStr(qrytemp.RecordCount);
    if   qrytemp.RecordCount> 0   then
    begin
        Application.MessageBox( '不能删除 ', '系统提示 ',MB_OK);
        Exit;
    end  
    可有的数据库表中的记录集就是0为什么还是不能删除,出现MessageBox对话框呢?

[解决办法]
qrytemp.SQL.Add( 'select count(*) from troom where classname= '+ QuotedStr(TreeView1.Selected.Text));
qrytemp.Open;
//Edit1.Text:= IntToStr(qrytemp.RecordCount);
if qrytemp.RecordCount> 0 then
begin
Application.MessageBox( '不能删除 ', '系统提示 ',MB_OK);
Exit;
end

呵呵,你用count会返回一行的,0也回返回0
if qrytemp.Fields[0].AsInteger > 0 then //这样试试!
begin
Application.MessageBox( '不能删除 ', '系统提示 ',MB_OK);
Exit;
end
[解决办法]
呵呵,正解~~

热点排行