Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

asp.net vb.net error messages from sqlserver

Posted on 2009-05-05
5
Medium Priority
?
212 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
[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
  • 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

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

719 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