Skip to main content

Crystal Reports Using Local Database


I receive one comment on one of my post “How to Print Using Crystal Reports” asking on how to create a crystal reports using a local database.

I told him to create a video on this, but I decided to create a project before I publish the video.

Local database has an extension filename “.sdf”. By default you cannot see it (Data Source) when you create crystal reports using a wizard.

There is no other way of displaying a report from local database other than hard coding.

You need to import “System.Data.SqlServerCe” in order to print crystal reports using local database.

Here’s the code to populate the DataSet in order to display the reports when you preview it.

  1. Dim sqlQRY As String = "SELECT * FROM Customers"
  2.  
  3. Dim cmdExec As SqlCeCommand = New SqlCeCommand(sqlQRY, conn)
  4.  
  5. 'create data adapter
  6. Dim da As SqlCeDataAdapter = New SqlCeDataAdapter(sqlQRY, conn)
  7.  
  8. 'create dataset
  9. Dim ds As DataSet = New DataSet
  10.  
  11. 'fill dataset
  12. da.Fill(ds, "Customers")
  13.  
  14. Dim Report As frmReports = New frmReports
  15.  
  16. Dim mReport As rptCustomers = New rptCustomers
  17.  
  18. mReport.SetDataSource(ds)
  19.  
  20. Report.CrystalReportViewer1.ReportSource = mReport
  21.  
  22. Report.ShowDialog()

 

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.

FOR YOUR OWN SAFETY, PLEASE:

1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

Comments

Submitted bysukamichi (not verified)on Mon, 05/14/2012 - 12:16

hi sir,

i think thats me .. hehe .. i just want to add up some question .. i think i'm using local database but the extension is .mdf not the .sdf you use in your program
is there any difference between the two ..

Submitted bysukamichion Mon, 05/14/2012 - 12:50

hehe .. it happens that i ask question regarding using crystal report with the local database as back end,
but i have some question about your program ..
your using the .sdf local database .. and it will really help me in my next program .. but i'm using the the other one with .mdf extension .. can you teach me on how to use it in .mdf database .. and by the way I check the program i downloaded here but there was an error .. the import system.data.sqlServerCe has a problem, it has a color green line on it .. do you how to debug it ..

thanks ..

Submitted bysukamichion Mon, 05/14/2012 - 13:47

hi,

the program is not working on my computer i think the import sqlserverce has an error .. it has a color yellow with a "!" on the inside .. i think i don't that reference in my computer i try to add reference but i can't see the dll file .. do you know how can i fix it ..

thankz ..

Submitted bysukamichion Tue, 05/15/2012 - 09:54

oh its working .. the problem is that i didn't have a dll file of system.data.sqlserverce and i try to download that dll and install it to my computer and it works ..

but how can i manage to deal with crystal report using serivce-based database(.mdf) ..

what i just did is to create a database inside the visual studio .net 2008(enterprise),i just add new item and add the serviced-based database(.mdf) to my project,and i begin to manipulate the databse,create table and everything ..

and it seems like it like a sqlserver with in your computer, like a local database,

Submitted byAnonymous (not verified)on Mon, 05/20/2013 - 14:00

why does my crystal report don't display the proper output ??
:/ i don't know what to do.. it's is the last thing that i have to finish but i don'y know what's wrong with my connection and database :///

Submitted bycrystaldecisio… (not verified)on Fri, 05/09/2014 - 04:44

crystaldecisions.reportsource.reportsourcefactory

this error ocurrs only in client computer on my computer that I have Visual studio 2010 doesn't show this message and works fine.

What is this?

Add new comment

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.