Page 1 of 1

Schema constraint violation on SQL Server 2008 R2

Posted: Wed 14 May 2014 06:48
by anwenkom
Hi,
I am getting the following exception on SQL Server 2008 R2:
Project SVP.exe raised exception class EOLEDBError with message 'OLE DB error occurred. Code 80040E21h

Parameter[0] :number - the data value violates the schema's constraint for the column (Status = Bh).'.
The same executable works just fine on SQL Server 2014.

The code is:

Code: Select all

  DataSet1 := CreateQuery('select distinct number as "nummer", behoerde, zusatz, strasse, ' + 'haus_nr, hsnr_zus, behoerde_plz, behoerde_ort, landkreis, land, art, einwohner, internet, wikipedia from behoerdenverzeichnis where (plz = :plz or :plz = '''') and (ort = :ort or :ort = '''')');
  DataSet1.ReadOnly := True;
  DataSource := TDataSource.Create(Self);
  DataSource.DataSet := DataSet1;
  DataSet2 := CreateQuery('select plz, ort from behoerdenverzeichnis where number = :number');
  DataSet2.MasterSource := DataSource;
  DataSet2.ReadOnly := True;
  DataSet2.Open;
Where CreateQuery is a simple function that creates a TMSQuery, sets the connection and assigns SQL.

I found a workaround that works on both 2008 R2 and 2014, but I don't want to change the code in many places. The workaround looks like this:

Code: Select all

DataSet1 := CreateQuery('select distinct number as "nummer", behoerde, zusatz, strasse, ' + 'haus_nr, hsnr_zus, behoerde_plz, behoerde_ort, landkreis, land, art, einwohner, internet, wikipedia from behoerdenverzeichnis where (plz = :plz or :plz = '''') and (ort = :ort or :ort = '''')');
  DataSet1.ReadOnly := True;
  DataSource := TDataSource.Create(Self);
  DataSource.DataSet := DataSet1;
  DataSet2 := CreateQuery('select plz, ort from behoerdenverzeichnis');
  DataSet2.MasterSource := DataSource;
  DataSet2.MasterFields := 'number';
  DataSet2.DetailFields := 'number';
  DataSet2.ReadOnly := True;
  DataSet2.Open;

Re: Schema constraint violation on SQL Server 2008 R2

Posted: Thu 15 May 2014 15:19
by azyk
Hi,

Thank you for the information. We have reproduced the problem and will investigate it.