If e.Name = "kj222" Then
If Network.Ping("DESKTOP-4HGMIGM\SQLEXPRESS",1000) = False Then '如果第一个IP无法接通
If Network.Ping("WIN-RR3MKL7U9ON\SQLSERVER2008",1000) = False Then '如果第二个IP无法接通
msgbox("出错")
Else
e.Connec tionS tring = "Pro vider=SQLO LEDB.1;Passw ord=kj222;Persist Sec urity Info=True;User ID=sa;Initial Cata log=BW_KJ222;Data Sour ce=WIN-RR3MKL7U9ON\SQLSERVER2008"
End If
End If
ELSE If e.Name = "BW_HR" Then
If Network.Ping("DESKTOP-4HGMIGM\SQLEXPRESS",1000) = False Then '如果第一个IP无法接通
If Network.Ping("WIN-RR3MKL7U9ON\SQLSERVER2008",1000) = False Then '如果第二个IP无法接通
msgbox("出错")
Else
e.Connectio nString = "Pro vider=SQLO LEDB.1;Pass word=kj222;Persist Secur ity Info=True;User ID=sa;Init ial Cat alog=BW_HR;Data Sou r ce=WIN-RR3MKL7U9ON\SQLSERVER2008"
End If
End If
End If