webForumDet fria alternativet

få fel meddeland när databasen är ner

ASP

2 svar · 181 visningar · startad av ShoGun

Medlem sedan aug. 2002237 inlägg
Frågan#1

jag vill ha en if sats som kollar om jag har
kontakt med databasen

så jag kan själv skriva ett felmedelande att det inte finns någon kontakt med databas samt att den skriver ut rästen av sidan.

så jag slipper asp fel meddelande

Medlem sedan nov. 20017 144 inlägg
#2

Du kanske kan mixtra ihop denna kod med solbulles kod jag hittade på en sökning, solbulles är för en komponent.


Dim Shl,fso,TextFile 
       Set Shl = Server.CreateObject("wscript.shell") 
       Shl.run "%comspec% /c ping 127.0.0.1 > testping.txt",0,true 
       Set Shl = nothing 
       Set fso = createobject("scripting.filesystemobject") 
       Set TextFile= fso.opentextfile("testping.txt") 
       Response.write TextFile.ReadAll 
        
       Set fso = Nothing 
       Set TextFile = Nothing

 url = "www.webforum.nu,[url]www.solbulle.com,www.hotmail.com[/url]"

arrayurl = Split(url, ",")

Set Pinger = Server.CreateObject("AspPing.Conn")

For i = 0 to ubound(url)

Pinger.RemoteHost = arrayurl(i)
Pinger.PingCount = 2

If Len(Pinger.Ping) Then
	Response.Write arrayurl(i) & " är Offline<br>"
Else
	Response.Write arrayurl(i) & " är Online<br>"
End If
Next
Set Pinger = nothing
%>
Medlem sedan okt. 20005 273 inlägg
#3

Skulle det inte räcka med On Error Resume Next...

Typ

[red]
On error Resume Next
'div databaskopplingar
If error <> 0 then
'Nått blev fel
Else
'allt är ok
End If
[/red]

som sagt typ nått sånt ;)

mvh icaaq

262 ms totalt · 4 externa anrop · v20260731065814-full.1dc6f849
120 ms — deklarationer (db)
0 ms — hämta statistik (cache)
134 ms — hämta tråd, inlägg och bilagor (db)
125 ms — ändringar (db)