can't determine which column violates unique index

G

Guest

In most of my tables I have an autoincrementing ID field
and one other field which also has a unique index. If I
get an error message telling me that the update cannot be
made because it violates this constraint, how can I
determine which column is the cause?

dennist
 
V

Val Mazur

Hi,

If you have one column, which is autoincrement and you do not update it,
then I would assume that problem relies in another column
 
K

Kevin Yu [MSFT]

Hi Dennist,

.Net framework doesn't seem to expose any methods or properties to let you
get which column violates the constraint when an ConstraintException is
thrown. However, you can get the error message using the
ContraintException.Message property. Please get reference from the
following link:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemdataconstraintexceptionmemberstopic.asp

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

--------------------
| Content-Class: urn:content-classes:message
| From: <[email protected]>
| Sender: <[email protected]>
| Subject: can't determine which column violates unique index
| Date: Tue, 4 Nov 2003 00:17:31 -0800
| Lines: 7
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcOirBeuG3EA1sIwRwCGyfXUh6+PNg==
| Newsgroups: microsoft.public.dotnet.framework.adonet
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.adonet:65322
| NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
| X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
|
| In most of my tables I have an autoincrementing ID field
| and one other field which also has a unique index. If I
| get an error message telling me that the update cannot be
| made because it violates this constraint, how can I
| determine which column is the cause?
|
| dennist
|
 
G

Guest

Kevin, thank you again for helping me. I haven't gotten
to it yet, but I will, and then let you know how it
turned out.

dennist
 
G

Guest

Kevin, I opened the page you mentioned and got the
following message:

Directory Listing Denied
This Virtual Directory does not allow contents to be
listed.
 
K

Kevin Yu [MSFT]

Hi DennisT,

Please combine the two line into one. It is a single URL. Or if you still
cannot open it, please go to msdn.microsoft.com and search
"ConstraintException Members (.NET Framework)" as keyword.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
--------------------
| Content-Class: urn:content-classes:message
| From: <[email protected]>
| Sender: <[email protected]>
| References: <[email protected]>
<[email protected]>
| Subject: RE: can't determine which column violates unique index
| Date: Wed, 5 Nov 2003 02:35:23 -0800
| Lines: 29
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcOjiIULXSxq3JeVTfusGb48KqH0qQ==
| Newsgroups: microsoft.public.dotnet.framework.adonet
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.adonet:65475
| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
|
| Kevin, I opened the page you mentioned and got the
| following message:
|
| Directory Listing Denied
| This Virtual Directory does not allow contents to be
| listed.
|
| >-----Original Message-----
| >Hi Dennist,
| >
| >.Net framework doesn't seem to expose any methods or
| properties to let you
| >get which column violates the constraint when an
| ConstraintException is
| >thrown. However, you can get the error message using the
| >ContraintException.Message property. Please get
| reference from the
| >following link:
| >
| >http://msdn.microsoft.com/library/default.asp?
| url=/library/en-us/cpref/html/
| >frlrfsystemdataconstraintexceptionmemberstopic.asp
| >
| >Kevin Yu
| >=======
| >"This posting is provided "AS IS" with no warranties,
| and confers no
| >rights."
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top