Original article: use crystal report in Visual Studio 2012
SAP released in January 14, 2013SAP Crystal Reports,Developer Edition for Microsoft Visual Studio-2012.
You can download from the following link:
Http://downloads.businessobjects.com/akdlm/cr4vs2010/CRforVS_13_0_5.exe
Download and install it on your computer. After installation, you can see the tools you are familiar.
Exercise is a review of the web page that uses crystal report to create reports. Create a table in SQL Server 2012:
CREATE TABLE [dbo].[CustomerOrders]( [CO] INT IDENTITY(1,1) NOT NULL PRIMARY KEY, [Item] NVARCHAR(40) NOT NULL, [Description] NVARCHAR(100) NULL, [Unit] NVARCHAR(10), [Quantity] INT NOT NULL, [Price] DECIMAL(18,4) NOT NULL )GO
Customerorders
After the table is created, add some records.
Insert into [DBO]. [customerorders] ([item], [description], [unit], [quantity], [price]) values ('w023-695-225 ', n' Mars ', N 'data', '3', '123. 56 '), ('w055-641-001', N 'saturn ', n', '2', '123. 43 '), ('t406-439-226', N 'global', n ', '6', '123. 81 '), ('201771-852-444', N 'mercurs', n ', '1', '123. 32'), ('u222-476-371 ', n' Jupiter', n', '8', '123. 55') Go
View code
Create a stored procedure that obtains all records and is available for Crystal Reports or Asp.net.
CREATE PROCEDURE [dbo].[usp_CustomerOrders_GetAll]ASSELECT [CO],[Item],[Unit],[Description],[Quantity],[Price],([Quantity] * [Price]) AS [Amount] FROM [dbo].[CustomerOrders]GO
Usp_customerorders_getall
Create a site in Visual Studio 2012, create a webpage, and pull the crystalreportviewer control into the webpage.
After the crystalreportviewer control is pulled, the webpage naturally generates the webpage yellow highlight code. Let's take a look at the code added in Web. config?
OK. Now we have to connect to the database, so we need to configure the web. config. Note that providername = "system. data. sqlclient "is used to quickly find the database when connecting to the database in the crystal report.
<connectionStrings> <add name="InsusConnectionString" connectionString="Server=127.0.0.1;Initial Catalog=Demo;User ID=Arrot;Password=5236$88;Packet Size=8192;Max Pool Size=1000;" providerName="System.Data.SqlClient"/> </connectionStrings>
View code
Next, create a customerorders. rpt crystal report on the website. For the creation process, see the following Animation:
After creating the crystalreport, let's take a look at the code generated by web. config:
Go to the insus. Net blog and download a DLL, which is a data communication component between Asp.net and SQL Server.
Http://www.cnblogs.com/insus/archive/2010/01/23/1654653.html
After decompression, move the DLL to the bin directory of the site.
Create an object in the app_code directory.
Now we can load custonerorders. rpt to the crystalreportviewer control:
Run the following command:
The pop-up window for exporting the button is as follows:
Diverse export formats:
Visual Studio 2012 use CRYSTAL REPORT