用Ado为例子,通过下面这种方法就可以。不可能提前知道具体的连接时间,道理很简单,因为网络环境是不确定,就是Sql server也经常是连接了很长时间最后才 报告无法连接的。注意设置好Connection对象的timeout属性! Function bConnectionSuccess () as boolean On error goto Errhand Connecionstr="........"
cn.Open Connection
msgbox "连接成功!" bConnectionSuccess =true Exit function Errhand: msgbox "无法连接网络" End Function
你可以得到,你的数据总量吧。
然后可以配合状态条的value值。
然后模拟一个loading窗口,
Function bConnectionSuccess () as boolean
On error goto Errhand
Connecionstr="........"
cn.Open Connection
msgbox "连接成功!"
bConnectionSuccess =true
Exit function
Errhand:
msgbox "无法连接网络"
End Function