Check Constraints AND ADO.NET

  • Thread starter Thread starter Polo
  • Start date Start date
P

Polo

Hi all,

I have a table where some columns have a constraint (datalength(Field1) > 0,
Field2 > 0)
When I use the Update method of the SqlDataAdapter to update the table, I
receive an error (a generic error)!
Why this error isn't generated in the RowUpdating event

Thank's in advance
Polo
 
Polo said:
Hi all,

I have a table where some columns have a constraint (datalength(Field1) > 0,
Field2 > 0)
When I use the Update method of the SqlDataAdapter to update the table, I
receive an error (a generic error)!
IMHO there is no such thing as a "generic error" in .NET, It would be
easier to help you if you copy&paste the exception message and
stacktrace in this forum.
Why this error isn't generated in the RowUpdating event
The answer to that could be hidden in the characteristics of the
exception...
 
The error message (In French):

Une exception non gérée du type 'System.Data.SqlClient.SqlException' s'est
produite dans system.data.dll

Informations supplémentaires : Erreur système.

Polo
 
The Message error :

Message "UPDATE statement conflicted with COLUMN CHECK constraint
'CK_Operator'. The conflict occurred in database 'PhotometricTechnicalData',
table 'Operator', column 'ID'." string

The problem is that this exception is generated by the update method.
Why this error doesn't appear in the rowUpdating event

Polo
 
Polo,

The most easy is to set the update in a try and catch block and than show
the exception in a message or in a commandline, whatever you want, than you
get much more information.

(This for testing purpose in real the catch has to be better)

I hope this helps,

Cor
 
Back
Top