Good afternoon, I can not understand how to disable the need to determine the keys and values in the request to T-SQL, I make a request to the server
SELECT Dates, Name, REPLACE(SpecialistName, 'ttt-', ''), WorkerName, PaymentTypeName, CASE InputPlace WHEN 'D' THEN 'Z' WHEN 'K' THEN 'Z' WHEN 'W' THEN 'Z' ELSE 'X' END, COUNT(*), SUM(CASE WHEN Code_Ref IS NOT NULL THEN 1 ELSE NULL END) AS [Обслужено] FROM Cards JOIN Xment ON XmentID = XmentID_Ref JOIN Worker ON WorkerID = MtorID_Ref LEFT JOIN Specialist ON SpecialistID = SpecialistID_Ref JOIN PaymentType ON PaymentTypeID = PaymentTypeID_Ref WHERE Dates BETWEEN '20150401' AND '20150414' AND HelpPlaceID_Ref = 1 GROUP BY Dates, Name, SpecficName, WorkerName, PaymentTypeName, InputPlace ORDER BY Dates, Name, SpecficName, WorkerName, PaymentTypeName, InputPlace and he returns to me
Could not enable restrictions. At least one line contains a value that violates restrictions on the absence of null values, uniqueness, or foreign keys.
in Management Studio everything works fine, but in the program it gives an error, part of the program code
InstallConnect.Open(); var StatConnect = InstallConnect.State; if (StatConnect.ToString() == "Open") { ValueStatusSQLC.StatusConnect = true; if (ValueStatusSQLC.ExecuteCommand) { ValueDataConnect.SendCommand.Connection = InstallConnect; ValueDataConnect.SendCommand.CommandText = ValueDataConnect.CodeQuery.ToString(); SqlDataReader ResultQuery = ValueDataConnect.SendCommand.ExecuteReader(); Thread CancelTransaction = new Thread(new ThreadStart(CancelQuery)); CancelTransaction.Start(); CancelTransaction.Join(); int CheckColums = ResultQuery.FieldCount; ValueDataConnect.TablesQuery.Load(ResultQuery); foreach (string Line in ListAnwers) { ComponentForm1.Invoke(new Action(() => ComponentForm1.richTextBox2.AppendText("SQL Server " + NameServer + " > " + Line + '\n'))); } InstallConnect.Close(); if (CheckColums != 0) { if (!ValueStatusSQLC.OpenOutputResultSql) { OutputResultSql StartForm = new OutputResultSql(); ComponentForm1.Invoke(new Action(() => StartForm.ShowDialog())); } else if (ValueStatusSQLC.OpenOutputResultSql) { OutputResultSql StartUpdate = new OutputResultSql(); } } else if (CheckColums == 0) { MessageBox.Show(ResultQuery.ToString(), "Результат соединения", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }