Answered by:
Problem in report Viewer

Question
-
User507801684 posted
Hey hi please help me on this...........
m working on report viewer m using this code b8 report viewer is not showing the report please any one solve the problem
reportViewer1.Visible = true;
var newDataSet = new DataSet();
SqlConnection sqlConnection = new SqlConnection("Data Source=ITAPX-SOLUTIONS\\SQLEXPRESS;Initial Catalog=Feb12Wali01;Integrated Security=True");
SqlDataAdapter sqlDataAdapter = new SqlDataAdapter();
SqlCommand sqlCommand = new SqlCommand();
sqlCommand.Connection = sqlConnection;
sqlCommand.CommandType = CommandType.Text;
sqlCommand.CommandText = "select * from SellDate";
// sqlCommand.Parameters.AddWithValue("@MerchantUID", ddlMerchants.SelectedValue);
sqlDataAdapter.SelectCommand = sqlCommand;
sqlDataAdapter.Fill(newDataSet,"empads");
ReportDataSource datasource = new ReportDataSource("empads", newDataSet.Tables[0]);
reportViewer1.LocalReport.DataSources.Clear();
reportViewer1.LocalReport.DataSources.Add(datasource);
reportViewer1.LocalReport.Refresh();
this.reportViewer1.RefreshReport();Saturday, March 3, 2012 3:07 AM
Answers
-
User-236691393 posted
Shahrukh,
I remember when I have to desgin and code for crystal reports using C#.NET, its a combination of things worked for me and then not.
If you are using just select statements to get data out, you should use dataset and if you have views, stored procedures from database I would rather suggest you to use direct connection from Crystal reports to database and then program it in C#.
I have to eventually landup using sample codes provided by CRYSTAL REPORTS
http://www.sdn.sap.com/irj/boc/samples?rid=/library/uuid/5050d3d0-19dd-2d10-ffb2-ddcd30a3e655
Please go through this and I hope you will not have any problems.
-------------------------------------------------------------------------------------------------------------------------------------------------------------
*If my post resolves your issue, please mark it as an answer.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, March 5, 2012 1:09 PM
All replies
-
User-236691393 posted
Shahrukh,
I remember when I have to desgin and code for crystal reports using C#.NET, its a combination of things worked for me and then not.
If you are using just select statements to get data out, you should use dataset and if you have views, stored procedures from database I would rather suggest you to use direct connection from Crystal reports to database and then program it in C#.
I have to eventually landup using sample codes provided by CRYSTAL REPORTS
http://www.sdn.sap.com/irj/boc/samples?rid=/library/uuid/5050d3d0-19dd-2d10-ffb2-ddcd30a3e655
Please go through this and I hope you will not have any problems.
-------------------------------------------------------------------------------------------------------------------------------------------------------------
*If my post resolves your issue, please mark it as an answer.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, March 5, 2012 1:09 PM -
User2105670541 posted
Hi... just wanted to know where you've passed the report name i mean "yourReportName.rdlc" ??
Tuesday, March 6, 2012 12:51 AM -
User-8475372 posted
Dear User,
It is always good to break up your code into methods. For it is easier to understand and looks clean.
Here, although you have mentioned the datasources to your report, you didnt pass the credentials to the report server. Take a look at the below snippet.
Microsoft.Reporting.WebForms.ReportParameter[] RptParameters; reportViewer.ServerReport.ReportServerUrl = new System.Uri(ConfigurationManager.AppSettings["ReportServerURL"]); reportViewer.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote; reportViewer.ToolBarItemBorderColor = System.Drawing.Color.PowderBlue; reportViewer.ToolBarItemBorderStyle = BorderStyle.Double; string strUserName = ConfigurationManager.AppSettings["UserName"].ToString(); string strPassword = ConfigurationManager.AppSettings["Password"].ToString(); string strDomain = ConfigurationManager.AppSettings["Domain"].ToString(); reportViewer.ServerReport.ReportServerCredentials = new ReportCredentials(strUserName, strPassword, strDomain); string strReport = string.Empty; strReport = ConfigurationManager.AppSettings["ReportsFolder"] + Request.QueryString["ReportName"].ToString();
Tuesday, March 6, 2012 5:12 AM