How to show user defined error messages in Windows application using c#?
(e.g) When duplicate value is entered in database, I have to show Already value exists in that name.....
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Piyush chhabra59 reputationPosted Apr 18, 2015, 9:16 AM EDT
you can throw the exception in the body of Method/function like this -->
public int MyFunction()
{
throw new NotImplementedException(" This is exception throwing Example );
}
Now for Checking in Database, You can simply run the query. For example you dont want the same Email address then use this query.
Now if there is any email address present in table then the value of temp will be 1 , Otherwise it will be 0. Now you can simply use If-Else
if(temp==1)
{
\\code to add email address
}
else
{
\\your Error Message
}
Gowtham RajamanickamRank #57 · 29K reputationPosted Apr 18, 2015, 9:19 AM EDT