# Avoid (disable) constraint check

**URL:** https://talk.remobjects.com/t/avoid-disable-constraint-check/32429
**Category:** Data Abstract
**Tags:** net
**Created:** [November 17, 2025, 3:24pm UTC](https://talk.remobjects.com/t/avoid-disable-constraint-check/32429 "2025-11-17T15:24:58Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![fvancrae](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/f/ad7895/32.png) [@fvancrae](https://talk.remobjects.com/u/fvancrae)
#### Post date: [November 17, 2025, 3:24pm UTC](https://talk.remobjects.com/t/avoid-disable-constraint-check/32429/1 "2025-11-17T15:24:58Z")

</div>

I was wondering if it is possible to disable constraints in the ReadDataTable

Due to simultaneous tasks my DB can become inconsistent.

I have a tool to rectify this by deleting records.

This operation does a ReadDataTable followed by a Delete of records.

I do it this way to trigger the server side business rules

However I get a constraint error on the read.

Probably because my primary key occurs twice in the DB.

Is there a way to disable the constraint?

 ![image](https://talk.remobjects.com/uploads/default/original/3X/e/8/e818a20cabc4de6b9f5188c43f4862e399cfa052.png)

I realise this is a bit of an excessive question/request. I understand if it is not possible.

An alternative would be to have a custom delete command which also triggers the server business rules.

Is this possible?

---

<div class="post-metadata">

### Author: ![fvancrae](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/f/ad7895/32.png) [@fvancrae](https://talk.remobjects.com/u/fvancrae)
#### Post date: [November 17, 2025, 3:28pm UTC](https://talk.remobjects.com/t/avoid-disable-constraint-check/32429/2 "2025-11-17T15:28:35Z")

</div>

Note: The error is in System.Data.DataTable but I assume RO sets them

---

<div class="post-metadata">

### Author: ![EvgenyK](https://talk.remobjects.com/user_avatar/talk.remobjects.com/evgenyk/32/16_2.png) [@EvgenyK](https://talk.remobjects.com/u/EvgenyK)
#### Post date: [November 17, 2025, 3:54pm UTC](https://talk.remobjects.com/t/avoid-disable-constraint-check/32429/3 "2025-11-17T15:54:40Z")

</div>

Hi,

You can update your table inside .daSchema and disable PK.

---

<div class="post-metadata">

### Author: ![fvancrae](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/f/ad7895/32.png) [@fvancrae](https://talk.remobjects.com/u/fvancrae)
#### Post date: [November 17, 2025, 4:20pm UTC](https://talk.remobjects.com/t/avoid-disable-constraint-check/32429/4 "2025-11-17T16:20:31Z")

</div>

Hi, I did not want to go this far. I assume the PK attribute has merrit.

I just want to change the constraint one time.

Can I make an onetime modification to the da schema?

FYI: This is my code

var streamer = new RemObjects.DataAbstract.Bin2DataStreamer(tabledata, RemObjects.DataAbstract.StreamerInitialization.ReadFromBeginning);  
var dataTable = new System.Data.DataTable(tablename);  
streamer.ReadDataTable(streamtablename, dataTable, true,true /\*_also tried false_\*/);

…

---

<div class="post-metadata">

### Author: ![fvancrae](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/f/ad7895/32.png) [@fvancrae](https://talk.remobjects.com/u/fvancrae)
#### Post date: [November 17, 2025, 4:38pm UTC](https://talk.remobjects.com/t/avoid-disable-constraint-check/32429/5 "2025-11-17T16:38:39Z")

</div>

FYI: I think I found the solution myself:

This works

var dataTable = new System.Data.DataTable(tablename);  
using (DataSet ds = new DataSet() { EnforceConstraints = false })  
{  
ds.Tables.Add(dataTable);  
streamer.ReadDataTable(streamtablename, dataTable, true, true);  
ds.Tables.Remove(dataTable);  
}

Thanks stack overflow 😉

---

<div class="post-metadata">

### Author: ![EvgenyK](https://talk.remobjects.com/user_avatar/talk.remobjects.com/evgenyk/32/16_2.png) [@EvgenyK](https://talk.remobjects.com/u/EvgenyK)
#### Post date: [November 17, 2025, 4:40pm UTC](https://talk.remobjects.com/t/avoid-disable-constraint-check/32429/6 "2025-11-17T16:40:30Z")

</div>

Hi,

You can

- fill schema - `streamer.ReadDataTable(streamtablename, dataTable, true, false);`
- adjust schema manually
- load records - `streamer.ReadDataTable(streamtablename, dataTable, false, true);`
