how to show crystal reports in visual studio 2005? [Resolved]

Posted by Hariinakoti under VB.NET on 12/27/2012 | Points: 10 | Views : 2045 | Status : [Member] | Replies : 1
Hi All,
How to show crystal reports in Visual Studio 2005?
I wrote this code for reports,entire code is working but i didn't get output.Please check my code once.

Code:

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Partial Class _Default
Inherits System.Web.UI.Page
Dim con As SqlConnection
Dim da As New SqlDataAdapter
Dim ds As DataSet
Dim cmd As New SqlCommand
Protected Sub btnSingle_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSingle.Click
CrystalReportViewer1.Visible = True
con = New SqlConnection(ConfigurationManager.ConnectionStrings("dbcon").ToString())
con.Open()
Dim rptdoc As New ReportDocument
ds = New DataSet
cmd.CommandText = "sp_studentrec"
cmd.CommandType = CommandType.StoredProcedure
cmd.Connection = con
cmd.Parameters.Add("@Sno", SqlDbType.Int).Value = txtsno.Text
da.SelectCommand = cmd
da.Fill(ds)
rptdoc.Load(Server.MapPath("CryStudentReport.rpt"))
rptdoc.SetDataSource(ds)
CrystalReportViewer1.ReportSource = rptdoc
con.Close()
End Sub

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
CrystalReportViewer1.Visible = False
End Sub
End Class

Thanks & Regards
Hari



Responses

Posted by: Hariinakoti on: 12/27/2012 [Member] Starter | Points: 25

Up
0
Down

Resolved
I got Solution friends

con = New SqlConnection(ConfigurationManager.ConnectionStrings("dbcon").ToString())
con.Open()
Dim rptdoc As New ReportDocument
Dim dt As New DataTable
ds = New DataSet
cmd.CommandText = "sp_studentrec"
cmd.CommandType = CommandType.StoredProcedure
cmd.Connection = con
cmd.Parameters.Add("@Sno", SqlDbType.Int).Value = txtsno.Text
da.SelectCommand = cmd
da.Fill(ds)
dt = ds.Tables(0)
rptdoc.Load(Server.MapPath("CryStudentReport.rpt"))
rptdoc.SetDataSource(dt)
CrystalReportViewer1.ReportSource = rptdoc
CrystalReportViewer1.Visible = True
con.Close()

Thanks & Regards
Hari

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response