How to replace visual studio 2010 default errors/critical messages?

Hello,

I want to replace visual studio 2010 default errors/critical messages with my own. Specific message in my application is "duplicate record found".

I want to add code before below one.
me.tblActualBindingSource.AddNew()

Open in new window


In MS access that very easy to replace, for example, Err 2019...
I have add message as picture file.

Thank you in advance for help to anyone.
duplicateMessage.bmp
dejandejanovicAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dirk HaestProject managerCommented:
You should implement a try-catch event
There you can catch all the errors and depending of the error, give you own message

http://www.vbdotnetheaven.com/uploadfile/rajeshvs/dotnetexception04162005022135am/dotnetexception.aspx

try
   me.tblActualBindingSource.AddNew()
Catch ex As SQLException
   if  ex.ErrorCode == 0x80131904 then
      ...
Catch ee As Exception
   Console.WriteLine("Exception")

finally
0
dejandejanovicAuthor Commented:
Thank you for reply Dhaest. I can not write your solution in right way.

Of course my plan is to prevent entry duplicate value in MSaccess database which has a primary key one of column.

I'm still learning vb.net, and this point is very hard.

Can you please assist?
thx.
0
dejandejanovicAuthor Commented:
I have found it by thinking for approx. 2h, but I'm glad I have learned by self.
Let me explain:
1. I have write query FirstNameCount1:
SELECT COUNT(FirstName) AS Expr1, FirstName
FROM  TEST
GROUP BY FirstName

Open in new window

2. Then added textbox to display query result from query column 3.

3. And in the end simple IF code

TextBox1.Text = qa.FirstNameCount1.Rows(0).Item(2)

Open in new window


  Dim qa = New Duplicate.TESTDataSetTableAdapters.TESTTableAdapter
        qa.FirstNameCount1()
        TextBox1.Text = qa.FirstNameCount1.Rows(0).Item(2)
        If TextBox1.Text >= 2 Then
            MsgBox("Duplicate")
        Else
            Me.Validate()
            Me.TESTBindingSource.EndEdit()
            Me.TableAdapterManager.UpdateAll(Me.TESTDataSet)
        End If

Open in new window


Is there a simpliest way to get a code "find duplicate before enty record" ?
0
Dirk HaestProject managerCommented:
There are 2 possibility's to perform this:
1. Check if there is already a record with this key (like you did)
remark: I would suggest to take a look at the executeScalar-method to get the count back. It's less overhead and quicker in execution thatn using a dataset
example: http://www.vb-helper.com/howto_net_get_set_data_value.html

2. Execute the insert-statement and catch the error. (see remark I posted earlier)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dejandejanovicAuthor Commented:
Thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.