ConstraintException catch speed

  • Thread starter Tom Garratt via .NET 247
  • Start date
T

Tom Garratt via .NET 247

I am using a try/catch block to catch a constraint exception whena new row is added or changed, like this:

Try
...
m_Contact.Tables(1).Rows.Add(dr)
...
Catch ex As Data.ConstraintException
MsgBox("This combination of user and location already exists!You can only select a unique combination.",MsgBoxStyle.Information)
End Try

However, on the first attempt at adding a user/location that arealready in the datatable, the constraint error takes a second orso to execute and move to the msgbox code. It is fine fromthereon after. Is there a way of speeding up this exceptionthrowing time? I suppose it would be the same for allexceptions.

Thanks, Tom
 
A

Andrew Conrad

Add a column versus simply setting a column value really isn't an apples to
apples comparision. In fact, it really depends on what indexes need to be
updated, the size of the table, number of constraints and expressions on
the table etc.
What does your table look like? What is the time difference you are seeing
with the constraints turned off.

Andrew Conrad
Microsoft Corp
http://blogs.msdn.com/aconrad/
 

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