Microsoft.Reporting 라이브러리에 문제가 있습니다. SQL보고 서비스에 액세스해야하며 보고서 이름, 서버 주소, 사용자 이름 및 암호가 있습니다. 우선 특정 보고서 하나에 필요한 모든 매개 변수를 가져와야합니다. 여기 자격 증명 - Microsoft보고 라이브러리
지금까지 내 구현 :using System;
using System.Collections.Generic;
using Microsoft.Reporting.WinForms;
namespace ConsoleApp1
{
class Program
{
static IEnumerable<DataSourceCredentials> CredentialsEnumerable()
{
var credentials = new DataSourceCredentials
{
Name = @"domain\account",
Password = @"password"
};
yield return credentials;
}
static void Main(string[] args)
{
var credentials = new DataSourceCredentials
{
Name = @"domain\account",
Password = @"password"
};
var report = new ReportViewer
{
ProcessingMode = ProcessingMode.Remote
};
report.ServerReport.ReportPath = @"/Archiv/Daily sales";
report.ServerReport.ReportServerUrl = new Uri(@"http://serverIPaddress/reportserver");
report.ServerReport.SetDataSourceCredentials(credentials);
foreach (var param in report.ServerReport.GetParameters())
{
Console.WriteLine(param.ToString());
}
Console.ReadLine();
}
}
}
하지만 내 코드를 중심으로 문제가 : 가능하지 키우면로부터 전송하는 것으로,
report.ServerReport.SetDataSourceCredentials(credentials);
나는 오류가 있어요 Microsoft.Reporting.WinForms.DataSourceCredentials to System.Collections.Generic.IEnumerable 나는 이미 변수 "자격 증명"을 사용하도록 tryid하고 IEnumerable 클래스를 만들었지 만 작동하지 않습니다.
내 코드가 잘못되었다고 제발 제안 해 주시겠습니까? 문제를 해결하고보고 서버에 대한 자격 증명을 제공하는 방법? 잘못된 자격 증명 매개 변수 - 나는 오류가 발생하고 자격 증명이없는
사전에
SetDataSourceCredentials에 단일 요소를 전달하고 있습니다. 그것은 배열을받을 것으로 예상됩니다. _report.ServerReport.SetDataSourceCredentials (Program.CredentialsEnumerable()); _ 또는 _report.ServerReport.SetDataSourceCredentials (새 DataSourceCredentials [] {credentials});로 간단하게 시도 했습니까 _ – Steve
예 tryed, not working. webbrowser를 사용하여 연결할 수 있지만 내 프로그램에서 여전히 "HTTP 401 : Unauthorized"오류가 발생합니다. –