读书人

adoquery 的记录集有关问题

发布时间: 2012-04-04 16:38:51 作者: rapoo

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
[解决办法]
呵呵,正解~~

读书人网 >.NET

热点推荐