• We just launched and are currently in beta. Join us as we build and grow the community.

Crystal Reports Using Local Database

saicle

Tech Efficiency Expert
S Rep
0
0
0
Rep
0
S Vouches
0
0
0
Vouches
0
Posts
87
Likes
146
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 200 XP
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. Dim

    cmdExec As

    SqlCeCommand =

    New

    SqlCeCommand(

    sqlQRY, conn)

  3. 'create data adapter
  4. Dim

    da As

    SqlCeDataAdapter =

    New

    SqlCeDataAdapter(

    sqlQRY, conn)

  5. 'create dataset
  6. Dim

    ds As

    DataSet =

    New

    DataSet

  7. 'fill dataset
  8. da.

    Fill

    (

    ds, "Customers"

    )

  9. Dim

    Report As

    frmReports =

    New

    frmReports

  10. Dim

    mReport As

    rptCustomers =

    New

    rptCustomers

  11. mReport.

    SetDataSource

    (

    ds)

  12. Report.

    CrystalReportViewer1

    .

    ReportSource

    =

    mReport

  13. 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.


Download
You must upgrade your account or reply in the thread to view the hidden content.
 

452,496

336,529

336,537

Top