| 发表于:2007-03-13 11:22:52 楼主 |
on error resume next strconnect = "persist security info=true " strconnect = strconnect & ";data source= " & j.jiemi(strhost) strconnect = strconnect & ";user id= " & j.jiemi(strdbuser) strconnect = strconnect & ";password= " & j.jiemi(strdbpass) strconnect = strconnect & ";initial catalog=psyp " with deyp.cnyp if .state = adstateopen then .close .provider = "sqloledb.1;network=dbmssocn " .connectionstring = strconnect .connectiontimeout = 30 .open end with if err <> 0 then frmunlink.show vbmodal err.clear end else end if on error goto 0 这是连接代码 是通过把主机ip.uid.pwd写在外部配置文件里面的.当网络断开或者以为其他原因无法连接服务器时.返回错误.请问该如何捕捉. 现在的判断方法是err <> 0则判断连接失败。弹出连接失败窗体出来。可是明明连接成功了还是弹出连接失败窗体出来呢。如果屏蔽掉frmunlink.show vbmodal这句又能正常连接. |
|
|
|
|