Last post Jan 26, 2018 10:00 AM by Eric Du
Jan 18, 2018 09:31 AM|Sugandan|LINK
Am trying to open a Crystal report in Crystal report viewer in VS2010. I had did the earlier in VS2008( I have Shared my code below).And this code worked fine in VS208. But am trying to do the same this in VS2010 but i couldn't . And when i googled i found
codes which has SetDataSource for ReportDocument Object . But where as if you see my below code which i used in VS2008 does not has to SetDataSource. I
just have to pass the parameter and Load the report. and it worked fine.Please help me out to figure out the issue as my current project is running on VS2010 and i have been told not to use setdataSource.
ConnectionInfo crConnectionInfo = new ConnectionInfo();
ReportDocument cryRpt = new ReportDocument();
string ConnectionString = "Data Source = 10.3.2.190; Database = ERP_THOMAS; User ID = ***; pwd = ***";
string connections = ConnectionString.Split(';');
crConnectionInfo.ServerName = connections.Substring(connections.LastIndexOf("=") + 1, connections.Length - (connections.LastIndexOf("=") + 1)).Trim();
crConnectionInfo.DatabaseName = connections.Substring(connections.LastIndexOf("=") + 1, connections.Length - (connections.LastIndexOf("=") + 1)).Trim();
crConnectionInfo.UserID = connections.Substring(connections.LastIndexOf("=") + 1, connections.Length - (connections.LastIndexOf("=") + 1)).Trim();
crConnectionInfo.Password = connections.Substring(connections.LastIndexOf("=") + 1, connections.Length - (connections.LastIndexOf("=") + 1)).Trim();
for (int i = 0; i < cryRpt.DataSourceConnections.Count; i++)
cryRpt.DataSourceConnections[i].SetConnection(crConnectionInfo.ServerName, crConnectionInfo.DatabaseName, crConnectionInfo.UserID, crConnectionInfo.Password);
CrystalReportViewer1.ReportSource = cryRpt;
Jan 19, 2018 06:16 AM|Eric Du|LINK
According to your description, you say can not load crystal report in VS2010, i want to know if you meet some error message? Please share them for us!
if you have crystall report installer for VS2010? if not, please check the following links:
Crystal report for visual studio 2010 is not working:
crystal report and visual studio 2010 problem:
Jan 21, 2018 05:06 AM|Sugandan|LINK
Thanks for the reply.
To put it more clear, when i try to load the Crystal report with above mentioned code only a blank page opens and it doesn't throws a error message.
And also please let me know if i can use Report Viewer control to display a crystal report .If Yes, kindly share with me how to load a crystal report in Report viewer control.
Jan 26, 2018 10:00 AM|Eric Du|LINK
Off course, you could load a crystal report in report viewer control, please check the following sample tutorial:
Beginners tutorial on how to load Crystal Reports using Crystal Report Viewer in Visual Studio 2012: