Crystal Reports for Visual Studio 2010 will be released separately, instead of included with the product.
Follow this link to download Crystal report for Visual Studio 2010, http://www.businessobjects.com/jump/xi/crvs2010/us2_default.asp
Click this highlighted link, download and install.
After finishing the installation you will not see any tool in the tool box. Then go to the “Project Properties” (if you have open new project in C#.net or VB.net) and find the Target Framework, you would see it as .Net Framework 4 Client Profile change this to be .NET Framework 4
Change as .NET Framework 4
When you change to .NET Framework 4 confirm it by click Yes
Now you can see Crystal Report Viewer in Tool Box.
string rptsqlstr = "";
ReplyDeleteSqlConnection con = new SqlConnection(strconn);
rptsqlstr = "select * from salesinfo";
SqlDataAdapter adp = new SqlDataAdapter(rptsqlstr, con);
DataTable tb = new DataTable();
adp.Fill(tb);
report.Load(Server.MapPath("Report\\Report1.rpt"));
report.SetDataSource(tb);
report.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Server.MapPath("Report/Report1.pdf"));
ClientScript.RegisterStartupScript(this.Page.GetType(), "popupOpener", "var popup=window.open('Report/Report1.pdf');popup.focus();", true);
add these headers-
ReplyDeleteusing System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Drawing.Imaging;
using System.Data.SqlClient;
using System.Data;
using CrystalDecisions.CrystalReports.Engine;
using System.Collections;
using System.Configuration;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
////declare a local private datatable and report document////
private ReportDocument report = new ReportDocument();
private DataTable gardeninfo = new DataTable();
u must include the refferences
ReplyDeleteInterop.CrystalActiveXReportViewerLib105.dll
Interop.CrystalReportViewerExportLib.dll
crystaldecisions.crystalreports.engine.
crystaldecisions.shared.
///bind data in combobox
ReplyDeletestring ddlbinding = "select cname from gardenname";
SqlConnection con = new SqlConnection(strconn);
SqlDataAdapter da = new SqlDataAdapter();
con.Open();
SqlCommand cmd = new SqlCommand(ddlbinding,con);
da.SelectCommand = cmd;
da.Fill(gardeninfo);
this.ddlgarden.DataSource = this.gardeninfo;
this.ddlgarden.DataValueField = "cname";
this.ddlgarden.DataBind();
///insert or update code///
string sqlstring1 = "INSERT INTO [TeaDashboard].[dbo].[salesinfo] ([Date],[garden],[salesno],[quantity],[avgrate]) values ('"+txtdate.Text+"','"+ddlgarden.Text+"','"+txtsalesno.Text+"','"+txtquantity.Text+"','"+txtavgrate.Text+"')";
SqlConnection con = new SqlConnection(strconn);
SqlCommand cmd = new SqlCommand(sqlstring1,con);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
very useful info..for more article like this visit http://www.webcodeexpert.com/
ReplyDelete