Help with ReportViewer ServerReport.SetDataSourceCredentials()

Welcome Forums General PowerShell Q&A Help with ReportViewer ServerReport.SetDataSourceCredentials()

Viewing 1 reply thread
  • Author
    Posts
    • #233776
      Participant
      Topics: 1
      Replies: 1
      Points: 14
      Rank: Member

      I’m basically trying to mimic some C# code and really struggling with it.

      C#:
      DataSourceCredentials cred = new DataSourceCredentials();
      ReportDataSourceInfoCollection dataSource = rv.ServerReport.GetDataSources();
      cred.Name = dataSource.First().Name;
      cred.UserId = “admin”;
      cred.Password = “pass”;
      rv.ServerReport.SetDataSourceCredentials(new DataSourceCredentials[] { cred });

      My attempt:
      $DataSource = New-Object Microsoft.Reporting.WinForms.DataSourceCredentials
      $DataSource.Name = $rv.ServerReport.GetDataSources().Name
      $DataSource.UserID = “admin”
      $DataSource.Password = “pass”
      $rv.ServerReport.SetDataSourceCredentials($DataSource)

      Any help? Thanks!

    • #233779
      Participant
      Topics: 1
      Replies: 1
      Points: 14
      Rank: Member

      figured it out..

      $DataSource = New-Object Microsoft.Reporting.WinForms.DataSourceCredentials
      $DataSource.Name = $rv.ServerReport.GetDataSources().Name
      $DataSource.UserID = “admin”
      $DataSource.Password = “pass”
      $rv.ServerReport.SetDataSourceCredentials([Microsoft.Reporting.WinForms.DataSourceCredentials[]]$DataSource)

Viewing 1 reply thread
  • You must be logged in to reply to this topic.