0

データベーステーブルからいくつかのデータを表示しようとしていますが、メッセージが表示されています。

"Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints."

5 月のクエリは..

SELECT        tblEmployeeInfo.EmpCode, tblEmployeeInfo.EmpName,     tblEmployeeInfo.EmpDepart, tblEmployeeInfo.EmpDesig, tblAtData.card_no, CONVERT(varchar, 
                         CONVERT(datetime, tblAtData.d_card), 112) AS Date,     CAST(LEFT(MIN(tblAtData.t_card), 2) + ':' + RIGHT(LEFT(MIN(tblAtData.t_card), 4), 2) 
                     + ':' + RIGHT(LEFT(MIN(tblAtData.t_card), 6), 2) AS TIME) AS Entrytime, CASE WHEN (CAST(LEFT(MAX(tblAtData.t_card), 2) 
                     + ':' + RIGHT(LEFT(MAX(tblAtData.t_card), 4), 2) + ':' + RIGHT(LEFT(MAX(tblAtData.t_card), 6), 2) AS TIME)) 
                     > tblSettings.StOutTime THEN tblSettings.StOutTime WHEN (CAST(LEFT(MAX(tblAtData.t_card), 2) + ':' + RIGHT(LEFT(MAX(tblAtData.t_card), 4), 2) 
                     + ':' + RIGHT(LEFT(MAX(tblAtData.t_card), 6), 2) AS TIME)) <= tblSettings.StOutTime THEN (CAST(LEFT(MAX(tblAtData.t_card), 2) 
                     + ':' + RIGHT(LEFT(MAX(tblAtData.t_card), 4), 2) + ':' + RIGHT(LEFT(MAX(tblAtData.t_card), 6), 2) AS TIME)) END AS OutTime, DATEDIFF(hour, 
                     CAST(LEFT(MIN(tblAtData.t_card), 2) + ':' + RIGHT(LEFT(MIN(tblAtData.t_card), 4), 2) AS TIME), CAST(LEFT(MAX(tblAtData.t_card), 2) 
                     + ':' + RIGHT(LEFT(MAX(tblAtData.t_card), 4), 2) AS TIME)) AS WH, CASE WHEN (DATEDIFF(hour, CAST(LEFT(MIN(tblAtData.t_card), 2) 
                     + ':' + RIGHT(LEFT(MIN(tblAtData.t_card), 4), 2) AS TIME), CAST(LEFT(MAX(tblAtData.t_card), 2) + ':' + RIGHT(LEFT(MAX(tblAtData.t_card), 4), 2) AS TIME)) 
                     - tblSettings.StWH) <= 0 THEN '0' WHEN (DATEDIFF(hour, CAST(LEFT(MIN(tblAtData.t_card), 2) + ':' + RIGHT(LEFT(MIN(tblAtData.t_card), 4), 2) AS TIME), 
                     CAST(LEFT(MAX(tblAtData.t_card), 2) + ':' + RIGHT(LEFT(MAX(tblAtData.t_card), 4), 2) AS TIME)) - 8) >= 2 THEN tblSettings.StOTH END AS OT, 
                     CASE WHEN CONVERT(datetime, (CAST(LEFT(MIN(tblAtData.t_card), 2) + ':' + RIGHT(LEFT(MIN(tblAtData.t_card), 4), 2) + ':' + RIGHT(LEFT(MIN(tblAtData.t_card),
                      6), 2) AS TIME))) > CONVERT(datetime, tblSettings.StEntryTime, 8) THEN 'Late' END AS ComingSate
FROM            tblEmployeeInfo INNER JOIN
                     tblAtData ON tblEmployeeInfo.EmpCardID = tblAtData.card_no INNER     JOIN
                     tblSettings ON tblSettings.StName = 'Setting'
WHERE        (tblAtData.d_card BETWEEN @sd AND @ed) AND (tblEmployeeInfo.EmpCode = @cd)
GROUP BY tblEmployeeInfo.EmpCode, tblEmployeeInfo.EmpName, tblEmployeeInfo.EmpDepart,     tblEmployeeInfo.EmpDesig, tblAtData.card_no, tblAtData.d_card, 
                     tblSettings.StEntryTime, tblSettings.StOTH, tblSettings.StWH,     tblSettings.StOutTime
   ORDER BY tblAtData.d_card DESC

そしてC#コードは...

DateTime date = Convert.ToDateTime(RadDatePicker1.DbSelectedDate);    
DateTime date1 = Convert.ToDateTime(RadDatePicker2.DbSelectedDate);

    string st = date.ToString("yyyyMMdd");

    string st1 = date1.ToString("yyyyMMdd");


    AttendanceDataSetTableAdapters.tblAtData4TableAdapter adptAtnRange = new AttendanceDataSetTableAdapters.tblAtData4TableAdapter();
    AttendanceDataSet.tblAtData4DataTable tblAtnRange = new AttendanceDataSet.tblAtData4DataTable();

    adptAtnRange.FillAllRange((tblAtnRange), st, st1, RadTextBox1.Text);

    ReportDataSource mds = new ReportDataSource("DataSetByRange", (DataTable)tblAtnRange);

    this.ReportViewer1.LocalReport.DataSources.Clear();
    this.ReportViewer1.LocalReport.ReportPath = Server.MapPath("AttendenceByRange.rdlc");
    //this.ReportViewer1.LocalReport.DataSources.Add(mds);
    this.ReportViewer1.LocalReport.DataSources.Add(mds);
    this.ReportViewer1.LocalReport.Refresh();
4

1 に答える 1