mam silnie typami zestawu danych, który generuje ten błąd dla wartości null,Jak znaleźć kolumnę, która narusza ograniczenia?
System.Data.ConstraintException: failed umożliwienie ograniczenia. Jeden lub więcej wierszy zawiera wartości naruszające ograniczenia inne niż zerowy, unikatowe lub obcego klucza . w System.Data.DataTable.EnableConstraints() w System.Data.DataTable.EndLoadData() w System.Data.Common.DataAdapter.FillFromReader zbiorze (DataSet, DataTable DataTable, String srcTable, DataReaderContainer dataReader, Int32 startRecord, Int32 MaxRecords, DataColumn parentChapterColumn, Przedmiot parentChapterValue) w System.Data.Common.DataAdapter.Fill (DataTable [] DataTables, IDataReader dataReader, Int32 startRecord, Int32 MaxRecords) w System.Data.Common.DbDataAdapter.FillInternal (zestaw danych dataset, DataTable [] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, Polecenie IDbCommand, zachowanie CommandBehavior) na System.Data.Com mon.DbDataAdapter.Fill (DataTable [] DataTables, Int32 startRecord, Int32 MaxRecords, polecenie IDbCommand, CommandBehavior zachowanie) w System.Data.Common.DbDataAdapter.Fill (DataTable dataTable) w Fruits.DataAccess.FruitsTableAdapters.FruitsExtTableAdapter. GetFruits (String użytkownika, filtr String) w Fruits.DataAccess.FruitsDataAccess.GetFruits (String użytkownika, String Filter) w Fruits.WebServices.External.Fruity.GetFruits (String Filter)
cały kolumny są wypełnione jednym wierszem testuję go,
USE [FruitDataBase]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Fruits](
[ID] [int] NOT NULL,
[CategoryID] [int] NOT NULL,
[Title] [nvarchar](255) NOT NULL,
[URL] [nvarchar](255) NOT NULL,
[Status] [nvarchar](70) NOT NULL,
[Description] [nvarchar](1024) NULL,
[User1] [nvarchar](50) NOT NULL,
[Date] [datetime] NOT NULL,
[User2] [nvarchar](50) NULL,
[Date2] [datetime] NULL,
[Impact] [nvarchar](255) NULL,
[Solution] [nvarchar](1024) NULL,
CONSTRAINT [PK_Fruits] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Fruits] WITH CHECK ADD CONSTRAINT [FK_Fruits_Categories] FOREIGN KEY([CategoryID])
REFERENCES [dbo].[Categories] ([ID])
GO
ALTER TABLE [dbo].[Fruits] CHECK CONSTRAINT [FK_Fruits_Categories]
GO
krótka odpowiedź: nie można zrobić kilka złośliwych plików z dynamicznym sql, ale nie radziłbym. – Tristan
Dzięki @Tristan, zmieniłem moje pytanie teraz – Mathematics
Wypróbuj 'WYBIERZ f. * Z DBO. Owoce AS f GDZIE NIE ZNAJDUJE SIĘ (WYBIERZ 1 Z dbo.Categories AS c WHERE c.id = f.categoryID);' aby znaleźć wiersze naruszać ograniczenie FK. –