冰
冰冷的雨
Unregistered / Unconfirmed
GUEST, unregistred user!
请指教,谢谢!<br>代码如下,adoqBCDef和adoqBaseCode两个ADOQuery共用一个ADOConnection。<br>把红色部分注释掉能正常运行。<br>请注意,不管把adoqBCDef改成什么名字,错误信息中指出的对象实例都是“adoqBaseCode”<br>[black]procedure TForm1.FormCreate(Sender: TObject);<br>var<br> strSQL: string;<br>begin<br> strSQL := 'SELECT * FROM BCDefTable';[/black]<br><br>[red] with adoqBCDef do<br> begin<br> Close;<br> SQL.Clear;<br> SQL.Append(strSQL);<br> Open; //运行到此句出错<br> //错误信息是:<br> // adoqBaseCode:cannot perform this operation on a closed dataset<br> ExecSQL;<br> end;[/red]<br>[black]<br> strSQL := 'SELECT * FROM BaseCodeTable';<br> with adoqBaseCode do<br> begin<br> Close;<br> SQL.Clear;<br> SQL.Append(strSQL);<br> Open;<br> ExecSQL;<br> end;<br>end;[/black]