I just deployed my first SSRS Report on Report Server and called it from application using ReportViewer (had to use it). Problem is, it always asks for database username and password before the execution of report. No matter where I set database credentials (on report server, in report) it always asks me for them. So I tried to set data source credentials programmatically like this:
DataSourceCredentials cred = new DataSourceCredentials();
ReportDataSourceInfoCollection dataSource = ReportViewer1.ServerReport.GetDataSources();
cred.Name = dataSource.First().Name;
cred.UserId = "sa";
cred.Password = "admin_pass";
ReportViewer1.ServerReport.SetDataSourceCredentials(new DataSourceCredentials[] { cred });
ReportViewer1.ServerReport.Refresh();
and first page of report loads just fine. Unfortunatelly second page asks for credentials again, and if I don't type them again, report viewer shows an error like dataSource does not exist:
Cannot create a connection to data source 'DataSource2'. (rsErrorOpeningConnection)
Does anyone have this problem? How to solve it? Thanks!