how to connect sql server compact edition database to crystal report in c# - stack overflow

3
× marc_s 337k 52 590 780 Alex Jolig 512 3 19 1 Answer I'm trying to connect my SQL Server Compact Edition database to Crystal Report. I've been searching all day long and I've found many question related to it so far on other websites, but none had a working answer. I also found this question in this site which has asked for VB.Net solution. And this link which is all over the internet and has a confusing way to do it by XML, which I couldn't figure it out. There are other links with solutions in SQL Server and Access which don't help. SQL Server solution Access Solution I'm wondering is there a simple way to connect a SQL Server CE database to Crystal Report which actually works? c# crystal-reports sql-server-ce edited Sep 14 at 8:39 asked Sep 14 at 5:32 Why not create a object data source from SqlCe and then use it ? – PaRiMaL RaJ Sep 14 at 5:43 @PaRiMaLRaJ I have no idea what it means! – Alex Jolig Sep 14 at 5:45 So I found my solution thanks to this helpful CodeProject sample I will demonstrate an easier sample to make it easier to figure it out. Create a Winform and add a button and a CrystalReportViewer control to it. 1. Add a DataSet (*.xsd file) to your project using add -> New Items in solution explorer. After that, add a DataTable to the DataSet. 2. Add columns to DataTable . It's better to name them the same as the columns you are going to 3. Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required. How to connect SQL Server Compact Edition database to Crystal Report in C# sign up log in tour help stack overflow careers How to connect SQL Server Compact Edition database to Crystal Report ... http://stackoverflow.com/questions/25830404/how-to-connect-sql-server... 1 de 3 11/4/2014 1:48 PM

Upload: marbimon

Post on 24-Dec-2015

24 views

Category:

Documents


3 download

DESCRIPTION

Conexion Crystal Reports con SQL Server CE

TRANSCRIPT

Page 1: How to Connect SQL Server Compact Edition Database to Crystal Report in C# - Stack Overflow

×

marc_s

337k 52 590 780

Alex Jolig

512 3 19

1 Answer

I'm trying to connect my SQL Server Compact Edition database to Crystal Report. I've been searching all day

long and I've found many question related to it so far on other websites, but none had a working answer.

I also found this question in this site which has asked for VB.Net solution. And this link which is all over the

internet and has a confusing way to do it by XML, which I couldn't figure it out.

There are other links with solutions in SQL Server and Access which don't help.

SQL Server solution

Access Solution

I'm wondering is there a simple way to connect a SQL Server CE database to Crystal Report which actually

works?

c# crystal-reports sql-server-ce

edited Sep 14 at 8:39 asked Sep 14 at 5:32

Why not create a object data source from SqlCe and then use it ? – PaRiMaL RaJ Sep 14 at 5:43

@PaRiMaLRaJ I have no idea what it means! – Alex Jolig Sep 14 at 5:45

So I found my solution thanks to this helpful CodeProject sample

I will demonstrate an easier sample to make it easier to figure it out.

Create a Winform and add a button and a CrystalReportViewer control to it.1.

Add a DataSet (*.xsd file) to your project using add -> New Items in solution explorer. After that, add a

DataTable to the DataSet.

2.

Add columns to DataTable . It's better to name them the same as the columns you are going to3.

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, noregistration required.

How to connect SQL Server Compact Edition database to Crystal Report in C#

sign up log in tour help stack overflow careers

How to connect SQL Server Compact Edition database to Crystal Report ... http://stackoverflow.com/questions/25830404/how-to-connect-sql-server...

1 de 3 11/4/2014 1:48 PM

Page 2: How to Connect SQL Server Compact Edition Database to Crystal Report in C# - Stack Overflow

display on your report. The number of columns depends on how many columns should be displayed in

the Crystal report.

Add a Crystal Report into the project using add -> New Items and using the Report Wizard, choose

ADO.NET DataSets of the Project data source as the data source of the Crystal Report and select the

data table you just created in your DataSet, as the selected table of the Crystal Report.

4.

Click finish and your columns will automatically be added in CrystalReport .5.

Go to the button click event and write these codes in it.

private void btnGo_Click(object sender, EventArgs e)

{

CrReport2 objRpt = new CrReport2();

string query = "Select Name,Number from tblInfo"; //Your sql query

SqlCeConnection conn =

new SqlCeConnection(

@"Data Source=|DataDirectory|\myDB.sdf;Persist Security Info=False");

//Your connection

SqlCeDataAdapter adepter = new SqlCeDataAdapter(query, conn);

DsReport Ds = new DsReport(); //DsReport is my dataset

adepter.Fill(Ds, "customer"); //customer is my datatable in dataset

6.

How to connect SQL Server Compact Edition database to Crystal Report ... http://stackoverflow.com/questions/25830404/how-to-connect-sql-server...

2 de 3 11/4/2014 1:48 PM

Page 3: How to Connect SQL Server Compact Edition Database to Crystal Report in C# - Stack Overflow

marc_s

337k 52 590 780

Alex Jolig

512 3 19

objRpt.SetDataSource(Ds);

crystalReportViewer1.ReportSource = objRpt;

}

Enjoy your report :)7.

edited Sep 14 at 8:40 answered Sep 14 at 7:03

Not the answer you're looking for? Browse other questions tagged c# crystal-reports

sql-server-ce or ask your own question.

How to connect SQL Server Compact Edition database to Crystal Report ... http://stackoverflow.com/questions/25830404/how-to-connect-sql-server...

3 de 3 11/4/2014 1:48 PM