Getting old Crystal Reports into Visual Studio 2013/2015, a quick how to…

I had Crystal Reports on an old server.  It was time to make a decision regarding how to get the reports over to a new server quickly and at the same time avoid purchasing more software and enduring installations, testing, etc.  For now, I decided to put the reports in Visual Studio.  If you find yourself in a similar situation, then the information below may save you some time.  This is how I did it:

  • Closed all applications on my pc (Windows 7, 64-bit)
  • Installed this: http://scn.sap.com/docs/DOC-7824 (Support Pack 16, I MUST INSTALL the exe, NOT the msi or it will not properly integrate with Visual Studio), at the end of the installation it asked me if I would also like to install the 64 bit, I said no and all was well.
  • Rebooted pc
  • Copied this folder: C:\Inetpub\wwwroot\aspnet_client\ into the directory with my Visual Studio solution (I created a solution in Visual Studio called crystalReports) on my pc and inside the solution I imported the crystal report rpt file then I created an aspx file where (from the Toolbox > Reporting) I dragged a “CrystalReportViewer” and “CrystalReportSource” onto the code in Design view.  It will look like this:

” <CR:CrystalReportViewer ID=”CrystalReportViewer2″ DisplayToolbar=”True” DisplayStatusbar=”true” runat=”server” AutoDataBind=”true” />
<CR:CrystalReportSource ID=”CrystalReportSource2″ runat=”server”></CR:CrystalReportSource> “

The code behind has a Page_Init like this (if you leave out the init then you will most likely see issues when you try to view multiple records within the crystal report):

protected void Page_Init(object sender, EventArgs e)
{
ReportDocument reportdocument = new ReportDocument();
reportdocument.Load(Server.MapPath(“myCrystalReport.rpt”));
ConnectionInfo connectInfo = new ConnectionInfo()
{
ServerName = “servername\\SQLEXPRESS”,
DatabaseName = “dataInReport”,
UserID = “cheesyPoofs”,
Password = “chess”
};
reportdocument.SetDatabaseLogon(“cheesyPoofs”, “chess”);
foreach (CrystalDecisions.CrystalReports.Engine.Table tbl in reportdocument.Database.Tables)
{
tbl.LogOnInfo.ConnectionInfo = connectInfo;
tbl.ApplyLogOnInfo(tbl.LogOnInfo);
}
CrystalReportViewer2.ReportSource = reportdocument;
}

  • Run the aspx page and you should see the embedded crystal report running properly on your pc
  • You also need to install Support Pack 16 on whatever server you plan to run this Visual Studio application on so remember to do this before you publish your application to a server
  • You also need to copy this folder: C:\Inetpub\wwwroot\aspnet_client\ to the same location on the destination server
  • You might need to download the individual drivers to get a specific report working, I didn’t have to do this but it could be a possibility for you (i.e. https://dev.mysql.com/downloads/connector/odbc/3.51.html)
  • Misc Note: Cross reference web.config vs your ODBC. NOTE DSN entries mean you need an existing connection with that name.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Create a free website or blog at WordPress.com.

Up ↑

%d bloggers like this: