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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Piyush chhabraPosted Apr 18, 2015, 1:16 PM
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 RajamanickamPosted Apr 18, 2015, 1:19 PM