0% found this document useful (0 votes)
31 views15 pages

Crystal Report Creation

The document provides instructions to resolve an error by adding a startup tag to the App.config file to set the useLegacyV2RuntimeActivationPolicy attribute to true. It also describes changing the target framework from .NET client profile to .NET framework 4 and using Crystal Reports to display data from a dataset bound to a SQL query in a CrystalReportViewer control on a Windows form.

Uploaded by

Sachin Patil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views15 pages

Crystal Report Creation

The document provides instructions to resolve an error by adding a startup tag to the App.config file to set the useLegacyV2RuntimeActivationPolicy attribute to true. It also describes changing the target framework from .NET client profile to .NET framework 4 and using Crystal Reports to display data from a dataset bound to a SQL query in a CrystalReportViewer control on a Windows form.

Uploaded by

Sachin Patil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Error solved:

Go to App.config

Add uselegacy runtime=true in startup tag like given below

<?xml version="1.0"?>
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="PRG25_STUD_CRYSTAL_DEMO.Properties.Settings.dbStudentConnectionString"
connectionString="Data
Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\dbStudent.mdf;Integrated
Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
<startup useLegacyV2RuntimeActivationPolicy="true"><supportedRuntime version="v4.0"
sku=".NETFramework,Version=v4.0"/></startup></configuration>

Error solved:

Properties
Change

Target framework .net client profile

To

.net framework 4

Crystal report creation

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 System.Data.SqlClient;
using CrystalDecisions.CrystalReports.Engine;
namespace PRG25_STUD_CRYSTAL_DEMO
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string t1 = textBox1.Text.ToString();
SqlConnection con = new SqlConnection(@"Data
Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\dbStudent.mdf;Integrated
Security=True;User Instance=True");
SqlCommand com;
SqlDataAdapter a = new SqlDataAdapter();
DataSet d = new DataSet();
a = new SqlDataAdapter("select * from tbl_student where sno='"+t1+"' ", con);
a.Fill(d);
ReportDocument doc = new ReportDocument();
doc.Load(@"D:\PRG25_STUD_CRYSTAL_DEMO\PRG25_STUD_CRYSTAL_DEMO\CrystalReport3.rpt");
doc.SetDataSource(d.Tables[0]);
crystalReportViewer1.ReportSource = doc;
}
}
}

Form controls
Textbox
Button
crystalreportViewer

Add Dataset

Do in dataset

You might also like