Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

asp.net vb.net error messages from sqlserver

Posted on 2009-05-05
5
Medium Priority
?
217 Views
Last Modified: 2012-05-06
Need to know a  specific error returned by sqlserver. I need to know when sqlserver returns an error when try write a duplicate value in an indexed fileld.
0
Comment
Question by:rflorencio
  • 2
  • 2
5 Comments
 
LVL 10

Expert Comment

by:Christian de Bellefeuille
ID: 24308438
don't you use a try/catch statement?

try
    ' your query
catch ex as exception
   ' Do whatever you want when an error occur...
   MyLabel.Text = ex.Message
end try
0
 
LVL 1

Expert Comment

by:chuckdsc
ID: 24311195
use the try_catch block to capture the sqlexception as follows


Try

Catch e As SqlException

End Try
0
 

Author Comment

by:rflorencio
ID: 24318804
In this case what i need is if the error occurs when try write a duplicate value in an indexed field. I need to know if this error specifically happened and not other.
0
 
LVL 10

Accepted Solution

by:
Christian de Bellefeuille earned 2000 total points
ID: 24319046
rflorencio, use your imagination! :-)

Try to insert a duplicate, set a break point in your catch statement, and watch for exception variable (in the case i mentionned, it's ex.ErrorCode).  Once you got the code, simply add an IF...
0

Featured Post

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.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

885 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