Open visual studio and create new website after that right click on
your website and select Add new item in that select Crystal Report and
click Add
Before will go to details, let me overview first the concepts behind .Net Framework. In Visual Studio 2010, it is different configuration from the .Net version, by default, when you create a new .Net Framework 4 Windows Form Application; it uses the .Net Framework 4 Client Profile which is the default framework, not the standard .Net Framework 4. Instead, from the .Net Framework 4 Client Profile change it into .Net Framework 4 to enable the Crystal Report Viewer available on your Toolbox.
Before to configure the .Net Framework,
first you are going to save your project on your specific folder
because once the project could not be save, the dialog box appear to
save first the project to enable any changes made. If you forgot to save first, message box will display.
In Windows Applications – go to – Compile and scroll down, locate Advanced Compile Options… and click it!
Select the .Net Framework 4 and click OK to continue and another message that ask to change the target Framework for this project. Click Yes.
your website and select Add new item in that select Crystal Report and
click Add
After that add crystal report then it will prompt Crystal Report Gallery window in that select blank solution and click OK
A blank report will create in our application now click on CrystalReports menu under that select Database under that select Database Expert
After click on Database Expert now Database Expert wizard will open in that select Create New Section >> select OLE DB (ADO) >> in that click on + sign of OLE DB (ADO)
Now select Microsoft OLE DB Provider for SQL
Server and click Next (Here we can select SQL Native client option also
but sometimes during deployment if servers not contains this native
client it will throw error).
Server and click Next (Here we can select SQL Native client option also
but sometimes during deployment if servers not contains this native
client it will throw error).
Now enter SQL Server name, username, password and required database and click Next
After
enter credentials for your required database click Next then click
Finish (Here for my database I didn’t set any credentials for that
reason I didn’t enter userid and password details don’t get confused).
enter credentials for your required database click Next then click
Finish (Here for my database I didn’t set any credentials for that
reason I didn’t enter userid and password details don’t get confused).
After
click Finish now our database loaded in OLEDB (ADO) section >>
select your database >> select dbo >> select required tables
click Finish now our database loaded in OLEDB (ADO) section >>
select your database >> select dbo >> select required tables
Now open tables in that select required table and move to selected tables section and click OK
After
that Database Fields in Field Explorer populated with our required data
table now drag and drop the required fields from data table to reports
Details section
that Database Fields in Field Explorer populated with our required data
table now drag and drop the required fields from data table to reports
Details section
set parameter
set formula
give a name to the formula
set formula section
set formula
give a name to the formula
set formula section
Add crystal report viewer
if crystal report viewer is not coming on the tool box then u can get in this process
Crystal Report Viewer is an issue in Visual Studio 2010, sometimes does not appear in toolbox. In Visual Studio 2010, Crystal Reports is no longer available instead, it is provided by SAP and it can be installed before should be able to use. However, Crystal report has been a component of Visual Studio ever since first released in 2002 until VS2008 and its supports Crystal reports and Crystal Report Viewer functionality. If you have already Crystal Report installed in your Visual Studio and it happens your Crystal Report Viewer is not visible in your Toolbox. Just simply follow the basic steps.
Before will go to details, let me overview first the concepts behind .Net Framework. In Visual Studio 2010, it is different configuration from the .Net version, by default, when you create a new .Net Framework 4 Windows Form Application; it uses the .Net Framework 4 Client Profile which is the default framework, not the standard .Net Framework 4. Instead, from the .Net Framework 4 Client Profile change it into .Net Framework 4 to enable the Crystal Report Viewer available on your Toolbox.
Before to configure the .Net Framework,
first you are going to save your project on your specific folder
because once the project could not be save, the dialog box appear to
save first the project to enable any changes made. If you forgot to save first, message box will display.
In Windows Applications – go to – Compile and scroll down, locate Advanced Compile Options… and click it!
Select the .Net Framework 4 and click OK to continue and another message that ask to change the target Framework for this project. Click Yes.
c# code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
namespace WindowsFormsApplication18
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
CrystalReport1 objCr=new CrystalReport1();
CrystalDecisions.Shared.TableLogOnInfo tliCurrent = default(CrystalDecisions.Shared.TableLogOnInfo);
foreach (CrystalDecisions.CrystalReports.Engine.Table tbCurrent in objCr.Database.Tables)
{
tliCurrent = tbCurrent.LogOnInfo;
var _with1 = tliCurrent.ConnectionInfo;
_with1.ServerName = @"SWASH-DBS\SWASHSQLINT";
_with1.DatabaseName = "siv";
_with1.UserID = "sa";
_with1.Password = "siv123";
_with1.IntegratedSecurity = false;
tbCurrent.ApplyLogOnInfo(tliCurrent);
}
objCr.SetParameterValue("id", 1);
objCr.SetParameterValue("name", "lazreena");
crystalReportViewer1.ReportSource = objCr;
}
}
}
other process of c# codingusing System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
namespace WindowsFormsApplication18
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
CrystalReport1 objCr=new CrystalReport1();
CrystalDecisions.Shared.TableLogOnInfo tliCurrent = default(CrystalDecisions.Shared.TableLogOnInfo);
foreach (CrystalDecisions.CrystalReports.Engine.Table tbCurrent in objCr.Database.Tables)
{
tliCurrent = tbCurrent.LogOnInfo;
var _with1 = tliCurrent.ConnectionInfo;
_with1.ServerName = @"SWASH-DBS\SWASHSQLINT";
_with1.DatabaseName = "siv";
_with1.UserID = "sa";
_with1.Password = "siv123";
_with1.IntegratedSecurity = false;
tbCurrent.ApplyLogOnInfo(tliCurrent);
}
objCr.SetParameterValue("id", 1);
objCr.SetParameterValue("name", "lazreena");
crystalReportViewer1.ReportSource = objCr;
}
}
}
private void Form2_Load(object sender, EventArgs e)
{
cn.Open();
da = new SqlDataAdapter("select Item_ID,Category_ID,Item_Name from Inventory.ItemGeneral", cn);
dt.Clear();
dt.Reset();
da.Fill(dt);
CrystalReport1 rpt = new CrystalReport1();
rpt.SetDataSource(dt);
crystalReportViewer1.ReportSource = rpt;
}
{
cn.Open();
da = new SqlDataAdapter("select Item_ID,Category_ID,Item_Name from Inventory.ItemGeneral", cn);
dt.Clear();
dt.Reset();
da.Fill(dt);
CrystalReport1 rpt = new CrystalReport1();
rpt.SetDataSource(dt);
crystalReportViewer1.ReportSource = rpt;
}
after that u modify in app.confic file
<startup useLegacyV2RuntimeActivationPolicy="true" ><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
No comments:
Post a Comment