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
Hi... just wanted to know where you've passed the report name i mean "yourReportName.rdlc" ??
Ashutosh Pathak
Blog: http://catchcode.blogspot.com Please mark it as answer if it helps, as clicking on the button can save time of others :)
MCP,MCAD,MCSD,MCTS
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.
Muhammad Sha...
Member
32 Points
38 Posts
Problem in report Viewer
Mar 03, 2012 07:07 AM|LINK
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();
Inayat Rasoo...
Participant
836 Points
285 Posts
Re: Problem in report Viewer
Mar 05, 2012 05:09 PM|LINK
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.
Ashutosh Pat...
Contributor
5737 Points
1105 Posts
Re: Problem in report Viewer
Mar 06, 2012 04:51 AM|LINK
Hi... just wanted to know where you've passed the report name i mean "yourReportName.rdlc" ??
Blog: http://catchcode.blogspot.com
Please mark it as answer if it helps, as clicking on the button can save time of others :)
MCP,MCAD,MCSD,MCTS
Srikanth Kas...
Contributor
4289 Points
883 Posts
Re: Problem in report Viewer
Mar 06, 2012 09:12 AM|LINK
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();Srikanth Kasturi
Please "Mark As Answer" if my post serves purpose.