oConn.Errors.Count problem with DSN-Less connection

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • san1901
    New Member
    • Jul 2014
    • 1

    oConn.Errors.Count problem with DSN-Less connection

    I had an old application that uses ASP/ADO BVScript (Classic) to connect to a SQL Server via ODBC. Due to the fact that the present server (Win 2008 R2, IIS 7.0) will be retired soon, I am forced to move the application to a new server (also 2008 R2.) The new server does not support ODBC connections, only DSN-Less connection is permitted.
    I move the application to the new location without a problem and connect well to the database with the DSN-Less connection. But now the following section of code does not want to work. It always returns a no error code (0), even after an error. Other words, I cannot trap the error:

    <%
    Set oConn = Server.CreateOb ject("ADODB.Con nection")

    vDSN = "Provider=SQLOL EDB;User ID=userID;passw ord=password;In itial Catalog=SQLdb;D ata Source=Server"
    oConn.Connectio nString = vDSN
    oConn.Open

    '---Check for password--------------------------------
    Set objCmd = Server.CreateOb ject("ADODB.Com mand")
    Set objCmd.ActiveCo nnection = oConn

    objCmd.CommandT ext = "{CALL dbo.prVP ('" & CStr(AB) &_
    "','" & CStr(P) & "')}"

    objCmd.CommandT ype = adCmdText
    objCmd.Execute

    Response.Write oConn.Errors.Co unt
    Response.End

    If oConn.Errors.Co unt > 0 Then
    Set ObjErr = Server.CreateOb ject("ADODB.Err or")

    For Each ObjErr in oConn.Errors
    If ObjErr.Number <> 0 Then
    'Response.Write "<b>Number: </b>" & ObjErr.Number & "<br>"
    'Response.Write "<b>Description : </b>" & ObjErr.Descript ion & "<br>"
    'Response.Write "<b>Source: </b>" & ObjErr.Source & "<br>"
    'Response.Write "<b>SQLStat e: </b>" & ObjErr.SQLState & "<br>"
    'Response.Write "<b>NativeError : </b>" & ObjErr.NativeEr ror & "<br>"
    'Response.Write "<b>ErrHand ler: </b>" & "ERROR." & "<br>"
    blnCriticalErro r = True
    End If
    Next

    Set ObjErr = Nothing

    If blnCriticalErro r Then
    oConn.Errors.Cl ear
    %> <form method="GET" action="http://bytes.com/AuthoSerReqForm .asp"> <p align="left"><b ><font size="3" face="MS Sans Serif" color="#FF0000" >Invalid password.</font></b> <input type="submit" value="Try Again" name="B1"></p> <input type="hidden" name="SRID" value="<%=srid% >"> <input type="hidden" name="C" value="<%=c%>"> <input type="hidden" name="AB" value="<%=ab%>" > </form> <%
    objCmd.Close
    Set objCmd = Nothing

    oConn.Close
    Set oConn = Nothing

    Response.End
    End If
    End If
    %>

    Did anybody encounter this problem out there before?
    Thank for the help.
Working...