function RetrieveData(s:string;var ErrInfo:string):TADOQuery;
var
qry:TADOQuery;
begin
if not FrmDm.cn.connected then FrmDm.cn.connected:=true;
qry:=TADOQuery.Create(nil);
try
with qry do
begin
connection:=FrmDM.cn;
SQL.Add(s);
//显示查询的sql
application.MessageBox(pchar(s),'sql');//通过SQLServer的查询分析器查询到1条记录
Open;
//显示记录数
application.MessageBox(pchar(inttostr(recordcount)),'recordcount');//显示为0
result:=qry;
end; //end with
except
ErrInfo:='执行''' + s + '''时出错';
qry.Free;
result:=nil;
end;//end try
end;调用时传入实参s:='select yhbh,bmbh,bmmc,yhmc,yhmm from htyh where yhmc='y' and yhmm='3344520''
在SQLServer的查询分析器里查询到1条记录,
但通过该函数查询到的recordcount:=0;
百思不得其解啊
//显示记录数
last; <-------------go last一下试试看
application.MessageBox(pchar(inttostr(recordcount)),'recordcount');//显示为0
result:=qry;
Open;
Last;
application.MessageBox(pchar(inttostr(recordcount)),'recordcount');//显示为0
result:=qry;