我在程序中使用adodataset1连接sql2000数据库程序就1个按钮,点击后执行
try
adodataset1.close;
adodataset1.commandtext:='select * from mytable';
adodataset1.open;
except
adodataset1.close;
end;
然后将查询结果显示到dbgrideh中,一切正常。此时,如果我禁用网卡(断开网络),然后再启用网卡后,点击按钮后,就一直提示‘连接失败’,必须要重新启动程序后又能正常,有什么办法避免吗?
try
adodataset1.close;
adodataset1.commandtext:='select * from mytable';
adodataset1.open;
except
adodataset1.close;
end;
然后将查询结果显示到dbgrideh中,一切正常。此时,如果我禁用网卡(断开网络),然后再启用网卡后,点击按钮后,就一直提示‘连接失败’,必须要重新启动程序后又能正常,有什么办法避免吗?
adodataset1.close;
adodataset1.commandtext:='select * from mytable';
adodataset1.open;
except
AdoDataSet1.Connection.Connected := False;
AdoDataSet1.Connection.Connected := True;
end;
如果adodataset1重来没有open过(网络一直是断开的),直接赋值AdoDataSet1.Connection.Connected =true,或者 false,会溢出出错,怎么办?
如果因为网络不稳定,时断时续,adodataset 重来没有open过,在使用前就设置它的Connection的Connected屬性false->true,会出错啊?