Avoid (disable) constraint check

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?

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?

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

Hi,

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

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*/);

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 :wink:

Hi,

You can

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