[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

ADO Connection Object error object .description member unobtainable

Posted on 2007-07-26
8
Medium Priority
?
527 Views
Last Modified: 2012-06-27
I am trying to access the .Description property of an error object within the set of them in a ADO connection object. I am able to get the value of its SQLState property and return it in a response string but
when I tried to do the same for .Description, it does not seem to return a valid string...

I can also return OK the values of the .Number and .HelpFile datamembers in this string but not the .Description

I must be missing something fundamental here or there is no valid description value for the error I am encountering...the DB in question is MS Sql Server


set conn = Server.CreateObject("ADODB.Connection")

' next line opens DB ok (details omitted)
conn.Open strOpen

' I intentionally cause an error by using a non exist table

sqlStr = "Insert into tblActiveUnitsxxx (TrkID) Values ('00" + Trim(CStr(unitID)) + "')"
conn.Execute (sqlStr)

if conn.Errors.Count > 0 then
   set objErr = Server.CreateObject("ADODB.Error")
   markerText = "<marker strError='"&conn.Errors.Count&"'/>"
   response.write markerText
   
   for each objErr in conn.Errors
      if objErr.Number <> 0 then
         markerText = "<marker strError='"&objErr.Description&"'/>"
         'markerText = "<marker strError='"&objErr.SQLState&"'/>"
         response.write markerText  
      end if
   next
end if
0
Comment
Question by:smmsmm57
  • 4
  • 3
8 Comments
 
LVL 29

Accepted Solution

by:
leonstryker earned 1800 total points
ID: 19576509
Instead of conn.Errors.Count use regular Err.Number

if Err.Number <> 0 then
   markerText = "<marker strError='"&Err.Number&"'/>"
   response.write markerText
   markerText = "<marker strError='"&Err.Description&"'/>"
   response.write markerText  
end if

Leon
0
 

Author Comment

by:smmsmm57
ID: 19576565
THanks, I tried that aand I get the same result....I am able to display (upon return from this asp page) the
contents of the .number method, but trying to access the .description member cause it to generate an error....

Interestingly?, the value of the Err.Number member comes back as -2147217865...

I insert the same code in a test VB app that "makes the same mistake" and in the VStudio IDE I am able to see the contents of the .Description member contains ""Invalid object name 'tblActiveUnitsxxxx'."

for wahtever reason, it is not showing up in the asp page which, I believe has functionally the same code....

0
 
LVL 9

Assisted Solution

by:deathtospam
deathtospam earned 200 total points
ID: 19576568
Try commenting out the following line:

========================================

set objErr = Server.CreateObject("ADODB.Error")

========================================


-= DeathToSpam =-
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:smmsmm57
ID: 19576597
Based on Leon's comments, I have reduced the code to:

if Err.Number <> 0 then
   markerText = "<marker strError='"&Err.Number&"'/>"
   response.write markerText
   'markerText = "<marker strError='"&Err.Description&"'/>"
   'response.write markerText  
end if

If I leave it as is above, I get value of number back OK....

If I uncomment out access of .Description method, it blows up....

0
 
LVL 29

Expert Comment

by:leonstryker
ID: 19576685
How about just this:

    If Err.Number <> 0 Then
        response.Write Err.Number & ": " & Err.Description
    End If

Leon
0
 

Author Comment

by:smmsmm57
ID: 19576696
Writing these values to the response:

 markerText = "<marker strError='"&Err.SQLState&"'/>"
 response.write markerText
  markerText = "<marker strError='"&Err.Source&"'/>"
 response.write markerText
  markerText = "<marker strError='"&Err.NativeError&"'/>"
  response.write markerText
 markerText = "<marker strError='"&Err.HelpContext&"'/>"
response.write markerText


Produces these values when I get back to the caller

ISRPostUnitDOK: -2147217865
Microsoft SQL Native Client
Microsoft SQL Native Client
Microsoft VBScript runtime error
Microsoft VBScript runtime error

Any attempt to access .description and I have the asp page generate an internal server error on the return to the caller...
0
 
LVL 29

Expert Comment

by:leonstryker
ID: 19576747
That is strange. It should be straight forward. Take a look here:

http://msdn2.microsoft.com/en-us/library/sbf5ze0e.aspx

Leon
0
 

Author Comment

by:smmsmm57
ID: 19577533
It turns out that the description text had one or more single quote characters in it that messed up the processing of the string sent back...so what I am doing is parsing the string and removing single quote char(s) b4 sending it back.....thanks for the help though
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
What we learned in Webroot's webinar on multi-vector protection.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question