RDL Report not rendering

Viewed 621

I have this error when I generate the report.

Where can I set the connection of my rdl file?

AspNetCore.Reporting.LocalProcessingException: An error occurred during local report processing.;An error has occurred during report processing. Query execution failed for dataset 'DataSet1'. Login failed for user ''. ---> AspNetCore.ReportingServices.ReportProcessing.ProcessingAbortedException: An error has occurred during report processing.

Here's my code.

         const int extension = 1;

         var path = Path.Combine(_webHostEnvironment.WebRootPath, "Reports", "test.rdl");
           
         var parameters = new Dictionary<string, string> { { "rp1", "Test Value to parameter" } };

         var localReport = new LocalReport(path);
            
         var result = localReport.Execute(RenderType.Pdf, extension, parameters);
            
         return File(result.MainStream, "application/pdf");```

  [1]: https://i.stack.imgur.com/XkwzU.jpg
1 Answers

Change your code like below:-

 
private readonly IHostingEnvironment _webHostEnvironment;

public HomeController( IHostingEnvironment webHostEnvironment)
 {
           
            _webHostEnvironment = webHostEnvironment;
            System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);

 }





public async Task<IActionResult> Print()
 {

 string mimetype = "";

 int extension = 1;
 
 var path = $"{this._webHostEnvironment.WebRootPath}\\Reports\\test.rdlc";
 Dictionary<string, string> parameters = new Dictionary<string, string>();
 parameters.Add("rp1", "Test Value to parameter");
           
 LocalReport localReport = new LocalReport(path);

 var result = localReport.Execute(RenderType.Pdf, extension, parameters, mimetype);
        
 return File(result.MainStream, "application/pdf"); 

}

Also, don't forget to install some NuGet packages as needed.

Hope it will resolve your issue. for more details and connected things, you can read this article:-

http://blog.geveo.com/IntegratingRDLCReportsToNetCoreProjects

UPDATE

App.config

<connectionStrings>
  <add 
    name="MyConnectionString" 
    connectionString="Data Source=DESKTOP-N41V6ER\SQLEXPRESS;Initial 
    Catalog=MyDatabase;User ID=userName;Password=password"
    providerName="System.Data.SqlClient"
  />
</connectionStrings>

User ID and Password means using SQL credentials, not Windows, but still very simple - just go into your Security section of your SQL Server and create a new Login. Give it a username and password, and give it rights to your database.

AGAIN UPDATE(Data Source Connect)

enter image description here

Now select the object and click next:-

enter image description here

below, the design of a simple report that allows displaying the (assume)product data in your connected database. then click finish.

enter image description here

then click the ok button:-

enter image description here

then you will find your database table in dataset:-

enter image description here

now you can drag and drop your data, which place you want to show in your report file.

enter image description here

................................................................. .................................................................

AGAIN UPDATE(Data base Connect)

First right click on your report project- => Add=>New Item then you will show:-

enter image description here

above add an entity data model to the windows form project.then click Add.then:-

enter image description here

enter image description here

Above,click New Connection.

enter image description here

Above,click Continue.

enter image description here

Above, give your server name. my machine has just one (SQL server)installed for that i am using . and select SQL Server in Authentication box.

enter image description here

Above,then click Ok.you have obisouly select DB name which you want.

enter image description here

enter image description here

Above, type your DB name carefully which you already selected.

enter image description here

enter image description here

Above, I select my product table because I will show that. then click finish

Related