By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,162 Members | 1,066 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,162 IT Pros & Developers. It's quick & easy.

oConn.Errors.Count problem with DSN-Less connection

P: 1
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.CreateObject("ADODB.Connection")

vDSN = "Provider=SQLOLEDB;User ID=userID;password=password;Initial Catalog=SQLdb;Data Source=Server"
oConn.ConnectionString = vDSN
oConn.Open

'---Check for password--------------------------------
Set objCmd = Server.CreateObject("ADODB.Command")
Set objCmd.ActiveConnection = oConn

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

objCmd.CommandType = adCmdText
objCmd.Execute

Response.Write oConn.Errors.Count
Response.End

If oConn.Errors.Count > 0 Then
Set ObjErr = Server.CreateObject("ADODB.Error")

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.Description & "<br>"
'Response.Write "<b>Source: </b>" & ObjErr.Source & "<br>"
'Response.Write "<b>SQLState: </b>" & ObjErr.SQLState & "<br>"
'Response.Write "<b>NativeError: </b>" & ObjErr.NativeError & "<br>"
'Response.Write "<b>ErrHandler: </b>" & "ERROR." & "<br>"
blnCriticalError = True
End If
Next

Set ObjErr = Nothing

If blnCriticalError Then
oConn.Errors.Clear
%> <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.
Jul 29 '14 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.