#277 - Intercettare gli errori in fase di apertura di un database
Per intercettare eventuali errori in fase di apertura, quando si tenta di accedere ad un database, si può utilizzare questo semplice script.
<%
' intercetta errori e salta
on error resume next
set conn = Server.CreateObject("ADODB.Connection")
' questo genera un errore
StrConn = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = c:\test_db.mdb;"
Conn.Open strConn
' ... script...
' per mostrare tutti gli errori, in fase di debug
if Conn.Errors.Count>0 then
Response.write "<HR>Debug:<BR>"
Response.write "Impossibile aprire il database.<BR>"
Response.write "Ecco gli errori generati: <ol>"
for i = 0 to conn.Errors.Count -1
ErrNum = conn.Errors(i).Number
if ErrNum <> 0 then
Response.write "<li>ADO Error # " & ErrNum
Response.write "Descrizione " & conn.Errors(i).Description
Response.write "Source " & conn.Errors(i).Source
end if
next
Response.Write "</ol>"
end if
%>
Questo script dovrebbe restituire qualcosa come:
ADO Error # -2147467259Descrizione Could not find file 'c:\test_db.mdb'.Source Microsoft JET Database Engine
Approfondimenti
- Real Code Launch 2008: grazie!
- Membership API per SQL Server anche senza dbo
- Realizzare applicazioni ASP.NET sicure - Seconda parte
- Velocity: ADO.NET Distributed Cache
- SQL Server 2008 February CTP
- SQL Server 2008 rimandato al terzo trimestre
- Microsoft Security Bulletin di luglio 2008
- Uno sguardo a LINQ to SQL
- Installare ASP.NET ed i tool in un colpo solo
- SQL Server 2008 disponibile in RTM
- Una noisa limitazione di LINQ To SQL
- Microsoft Security Bulletin di settembre 2008
Commenti
Esprimi il tuo giudizio su questo script:
Per procedere devi essere autenticato.
Aggiungi un nuovo commento »»»
Per inserire un commento, devi registrarti alla nostra community.







Stampa
Download 


10annidi.ASPItalia.com: iscriviti alla competizione e vinci fantastici premi ogni mese!