Solved

How is the sql error message number returned in classic asp?

Posted on 2007-11-20
6
532 Views
Last Modified: 2012-08-13
How do I retrieve back the error number 2627 in classic asp?  In stored procedures I can return the error message but not with the below code.  Is there another object or function I could use?

Server: Msg 2627, Level 14, State 1, Line 1

ASP Code
rs.Open sql, con,, adLockOptimistic      
    If err.number <> 0 or con.Errors.Count > 0 Then  
           Response.Write(err.number)  
           Response.Write(err.description)
           Response.Write(con.errors.number)
           Response.Write(con.errors.description)          
    End If
0
Comment
Question by:swansonplace
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
6 Comments
 
LVL 25

Accepted Solution

by:
kevp75 earned 500 total points
ID: 20321475
please close the question:
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/ASP/Q_22973004.html

what you've done is create a 1000 point question which goes against the sites t.o.s.

as to your issue, is this from a stored procedure?  I ask because you could set a return value to equal:
            begin
                  raiserror('Your message',16,1)
                  return -1
            end


have a look here:
http://doc.ddart.net/mssql/sql70/ra-rz_1.htm
0
 

Author Comment

by:swansonplace
ID: 20327837
This is called from an asp page.  I know that in stored procedures this specific error can be returned, but using asp as in the code above, the I am not getting the sql duplicate error message.
0
 

Author Comment

by:swansonplace
ID: 20327885
Since I have posted the question for 24 hours, and received no responses.  My "ass"umption is that there is not easy way to get the specific sql return code from the inline asp call.  

The post with kevp75 was for stored procedures, and I am not using a stored procedure.  Below is
a snippet of the code, and the way I am retrieving the errors.

ASP Code
rs.Open sql, con,, adLockOptimistic      
    If err.number <> 0 or con.Errors.Count > 0 Then  
           Response.Write(err.number)  
           Response.Write(err.description)
           Response.Write(con.errors.number)
           Response.Write(con.errors.description)          
    End If

Thanks in advance.

0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 

Author Comment

by:swansonplace
ID: 20351472
Since I could not retrieve the sql error messages (am not using stored procedures),  I ended up creating a function that looked for the duplicate inserts, and that allowed me to give my users an error message.

0
 

Author Closing Comment

by:swansonplace
ID: 31427352
Thank you.
0
 

Author Comment

by:swansonplace
ID: 20407683
Tnank you.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Select record with the most recent date 14 72
Button function on table is in trouble 3 41
My Do While is Not Producing Anything 15 87
href return to normal window 5 44
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

739 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