Easy way to load crystal report in .NET

A way to load the crystal report with different method. There are two ways of attaching crystal report, 1. Direct method 2. By coding. Crystal report with the help of coding is displayed. It may be possible that whenever we are passing path,it may create some error. To avoid this, one more method is added over here. You can also find sample code as attached with this article.

Make a simple dataset,and a simple crystal report. Add datasources in crystal report with the help of Dataset. the make on new form in which a crystalreportviewer is added.

Write below code in load event of crystal report.

"Report Viewer coding"

Imports System.IO
Imports System.Data
Imports System.Data.SqlClient
Imports CrystalDecisions.CrystalReports.Engine
Public Class Form1
Dim strCon As String
Dim sCon As SqlConnection
Dim sCom As SqlCommand
Dim ssql As String
Dim sDa As SqlDataAdapter
Dim sDS As New DataSet1
Private Sub CrystalReportViewer1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CrystalReportViewer1.Load
strCon = "Data Source=.\SQLEXPRESS;AttachDbFilename=D:\Regarding Studies\windows App\Practicefinalcrystal\Practicefinalcrystal\db.mdf;Integrated Security=True;User Instance=True"
sCon = New SqlConnection(strCon)
ssql = "SELECT detail.*, purchase.*, detail.id AS Expr1 FROM detail INNER JOIN purchase ON detail.id = purchase.id WHERE(detail.id = 2)"
sCom = New SqlCommand(ssql, sCon)
sDa = New SqlDataAdapter(sCom)
sDa.Fill(sDS, "master")
Dim dt As New DataTable
dt = sDS.Tables("master")
Dim myreport As New ReportDocument
Dim d As New print
CrystalReportViewer1.ReportSource = myreport
End Sub
End Class


  • Easy way to load crystal report (44679-212437-Easy-way-load-crystal-report.rar)
  • Comments

    Author: Jivani25 Apr 2013 Member Level: Gold   Points : 2

    you can esily load crystal report to followlink follow

    this step by step information to generet crystal report
    and database to table create
    and datasset to datatable create


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: