Why am I getting a duplicate key value error when it isn't?
First, let me say that I'm very new to vb.net programming and especially working with MS SQL Server. Here's my problem:
The code in the attached file works well when creating a new row with new data. I then forced an error to test my "Catch" statement and it worked as well. My problem is that I then changed one of the text boxes from which the key value is created but I'm still getting the duplicate key value error. I used MessageBox to show that it was changing the key value so I don't understand what's happening. Do I need to initialize the Data Adapter or Data Table before I run this each time? Please keep any explanations simple enough for a newbie to understand. aaDuplicateError.docx
Visual Basic.NET
Last Comment
J. Ross Hughson
8/22/2022 - Mon
Scott McDaniel (EE MVE )
Without knowing more about your table setup it's hard to say, but you need to find out the actual error you're getting instead of returning your own. Try this in the Catch handler:
You really should Delete this question, since no solution was provided. I'm objecting, which will allow you to Delete the question instead of accepting a non-solution as the answer.
J. Ross Hughson
ASKER
There were no solutions offered that dealt with the problem.
Catch dbException As System.Data.SqlClient.SqlE
boolCreateBinderOK = False
MessageBox.Show("SQLExcept
Catch ex As Exception
boolCreateBinderOK = False
MessageBox.Show("Exception
Run it and report back what the issue is.