--- title: "Handling Errors in VBScript | Microsoft Docs" ms.prod: sql ms.prod_service: connectivity ms.technology: connectivity ms.custom: "" ms.date: "01/19/2017" ms.reviewer: "" ms.topic: conceptual dev_langs: - "VB" helpviewer_keywords: - "VBScript error handling [ADO]" - "errors [ADO], VBScript" ms.assetid: 31bc3743-32d3-4bc7-ac61-ee6ed0fdec70 author: MightyPen ms.author: genemi --- # Handling Errors in VBScript There is little difference between the methods used in Visual Basic and those used with VBScript. The primary difference is that VBScript does not support the concept of error handling by continuing execution at a label. In other words, you cannot use `On Error GoTo` in VBScript. Instead, use `On Error Resume Next` and then check both **Err.Number** and the **Count** property of the **Errors** collection, as shown in the following example: ``` Error Handling Example (VBScript)

Error Handling Example (VBScript)

<% Dim cnn1 Dim errLoop Dim strError On Error Resume Next ' Intentionally trigger an error. Set cnn1 = Server.CreateObject("ADODB.Connection") cnn1.Open "nothing" If cnn1.Errors.Count > 0 Then ' Enumerate Errors collection and display ' properties of each Error object. For Each errLoop In cnn1.Errors strError = "Error #" & errLoop.Number & "
" & _ " " & errLoop.Description & "
" & _ " (Source: " & errLoop.Source & ")" & "
" & _ " (SQL State: " & errLoop.SQLState & ")" & "
" & _ " (NativeError: " & errLoop.NativeError & ")" & "
" If errLoop.HelpFile = "" Then strError = strError & _ " No Help file available" & _ "

" Else strError = strError & _ " (HelpFile: " & errLoop.HelpFile & ")" & "
" & _ " (HelpContext: " & errLoop.HelpContext & ")" & _ "

" End If Response.Write("

" & strError & "

") Next End If %> ```