reportOption.ReportModel.DataSources.Clear();
reportOption.ReportModel.DataSources.Add(new ReportDataSource { Name = "DataSet1", Value = ds.Tables[0] });
//reportOption.ReportModel.DataSources.Add(new ReportDataSource { Name = "DataSet2", Value = ds2.Tables[0] }); |
You are loading the RDL report. Can we know the reason to supply the data source for the RDL Report from application? |
DataSourceCredentials dsc = new DataSourceCredentials();
dsc.ConnectionString = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=GirlsHaven;Column Encryption Setting=Enabled;";
dsc.IntegratedSecurity = false;
dsc.UserId = "******";
dsc.Password = "******";
dsc.Name = "GirlsHaven";
reportOption.ReportModel.DataSourceCredentials.Add(dsc);
reportOption.ReportModel.ProcessingMode = ProcessingMode.Local; |
If you are providing the data source from application with the understating of Local processing mode then why you are trying to changing the credential information in report? |
public void OnInitReportOptions(ReportViewerOptions reportOption)
{
string basePath = _hostingEnvironment.WebRootPath;
FileStream inputStream = new FileStream(basePath + @"\ReportData\Territory Sales.rdl", FileMode.Open, FileAccess.Read);
reportOption.ReportModel.Stream = inputStream;
}
public void OnReportLoaded(ReportViewerOptions reportOption)
{
SqlConnection connection = new SqlConnection("Data Source=dataplatformdemodata.syncfusion.com;Initial Catalog=AdventureWorks;User ID=demoreadonly@data-platform-demo;Password=N@c)=Y8s*1&dh;");
var strsql = "SELECT Top (50) ST.Name, SP.SalesPersonID, C.FirstName, C.LastName, SOH.SalesOrderNumber, SOH.TotalDue FROM Sales.SalesTerritory ST INNER JOIN Sales.SalesPerson SP ON ST.TerritoryID = SP.TerritoryID INNER JOIN HumanResources.Employee E ON SP.SalesPersonID = E.EmployeeID INNER JOIN Person.Contact C ON E.ContactID = C.ContactID INNER JOIN Sales.SalesOrderHeader SOH ON SP.SalesPersonID = SOH.SalesPersonID GROUP BY ST.Name, SP.SalesPersonID, C.FirstName, C.LastName, SOH.SalesOrderNumber, SOH.TotalDue ORDER BY ST.Name";
SqlDataAdapter adapter = new SqlDataAdapter(strsql, connection);
adapter.SelectCommand = new SqlCommand(strsql, connection);
DataSet ds = new DataSet();
adapter.Fill(ds);
reportOption.ReportModel.DataSources.Clear();
reportOption.ReportModel.DataSources.Add(new ReportDataSource { Name = "TerritorySales", Value = ds.Tables[0] });
} |
Queries |
Response |
The sample doesn't have any parameters. My report works fine with no parameters but my problem is I can't get parameters working. I have confirmed both dataset names match. The parameter dropdown in the reportviewer is locked and i can't click it. If I try textbox instead of dropdown, then it isn't applied to report on "View Report" click
I've attached a copy of the report so you can see what I'm trying to do, but basically if you created a DataSet2 "Select distinct SalesPersonID FROM Sales.SalesPerson" and based a parameter on DataSet2, defaulting to an empty string. |
We were able to reproduce the mention issue at our end in our essential studio version (16.4.0.42). We will get back to you with timeline details by tomorrow.
Please confirm the version you are using for additional information. |
I figured this out. The reportviewer just can't handle a query that returns a '' as the top value. This must be some sort of bug in the reportviewer, since I uploaded the same report to the syncfusion report server and sql server report server and it worked fine.
I had to rewrite my dataset queries to return an efor the parameter drop downs like so:
from
SELECT * FROM
(
SELECT '' AS PID /* Parameter Value and Label were both set to PID*/
UNION ALL
SELECT DISTINCT cIDNUM AS PID FROM tblChildren_c) a
to
SELECT * FROM
(
SELECT '0' AS PID, '' AS PIDlbl /* Parameter Value set to PID and Label set to PIDlbl */
UNION ALL
SELECT DISTINCT cIDNUM AS PID, cIDNUM AS PIDlbl FROM tblChildren_c) a |
We are still validating this issue at our end and will get back to you with further details by tomorrow. |