Как получить доступ к Visual Studio - Командные окна - `GetErrors` в этом контексте? - PullRequest
0 голосов
/ 26 сентября 2019

См. принятый ответ в этом вопросе , когда исключение обнаруживается в приведенном ниже коде, какой объект я должен использовать для доступа к GetErrors?

Где находится DataTable?

private void export(string strFormat, ReportViewer rv)
{
    try {
        ReportDataSource rptDataSource = new ReportDataSource("DataSet_GRN_Report", ObjectDataSource1);
        rv.LocalReport.DataSources.Add(rptDataSource);
        rv.LocalReport.Refresh();

        Warning[] warnings;
        string[] streamids;
        string mimeType;
        string encoding;
        string extension;
        string deviceInfo = null;
        string strContentType;


        if (strFormat.ToUpper() == "PDF")
        {
            deviceInfo = "<DeviceInfo><OutputFormat>EMF</OutputFormat>" +
                "  <PageWidth>11.69in</PageWidth>" +
                "  <PageHeight>8.27in</PageHeight>" +
                "  <MarginTop>0.15in</MarginTop>" +
                "  <MarginLeft>0.2in</MarginLeft>" +
                "  <MarginRight>0.15in</MarginRight>" +
                "  <MarginBottom>0.15in</MarginBottom>" +
                "  </DeviceInfo>";
            strContentType = "application/pdf";
        }
        else
        {
            strContentType = "application/vnd.ms-excel";
        }

        byte[] bytes = rv.LocalReport.Render(strFormat, deviceInfo, out mimeType, out encoding, out extension, out streamids, out warnings);
        Response.Clear();
        Response.Buffer = true;
        Response.ContentType = strContentType;
        Response.BinaryWrite(bytes);
        Response.End();
    }
    catch (Exception exception)
    {
        exception = exception;
    }
}

Исключение:

Не удалось включить ограничения.Одна или несколько строк содержат значения, нарушающие ненулевые, уникальные или ограничения внешнего ключа

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...