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?
 
DhaestConnect With a Mentor Commented:
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
 
DhaestCommented:
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
 
dejandejanovicAuthor Commented:
Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.