Prima esperienza con Crystal Report

martedì 10 dicembre 2013 - 11.17
Tag Elenco Tags  VB.NET  |  .NET 4.0  |  Crystal Reports 10.0

base_b Profilo | Newbie

Buongiorno,
vi vorrei sottoporre il mio problema:
per aggiungere un plus alla mia applicazione ASP.NET che consente di organizzare le informazioni importanti per le associazioni cinofile, volevo inserire una pagina di reportistica, semplicissima, contenente una stampa dei soggetti presenti nelle colonie, registrati in SQL Server.
Premetto di essere autodidatta, ma per lavoro ho già utilizzato Business Object e la reportistica Crystal Report, anche se c'era qualcuno che mi preparava i report secondo le mie indicazioni.

Volendo fare da sola, ho creato un report inserendo 4 campi:
ID_Dog
Nome soggetto
Nr_LOI
Data di nascita

In forma di elenco, senza subtotali o abbellimenti.

Ho creato la pagina Reports.aspx,
contenente un controllo
<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="True" />

Nel Code Behind ho aggiunto il Dataset:

Imports System.Data.SqlClient
Imports System.Data
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports System.Linq
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports System.Configuration

Public Class Reports
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Dim Conn As SqlConnection = New SqlConnection()
Conn.ConnectionString = "Data Source=.\SQLEXPRESS; Persist Security Info=False; Trusted_Connection=Yes; DATABASE=KENNELS"
Dim comm As SqlCommand = New SqlCommand()
comm.CommandType = CommandType.Text
comm.CommandText = "SELECT Dog_Name, Dog_Dob, Dog_Loi, Sex FROM T_Dogs"
comm.Connection = Conn
Dim MyAdapter As SqlDataAdapter = New SqlDataAdapter()
Dim MyDS As New DataSet()
Try
Conn.Open()

MyAdapter.SelectCommand = comm
MyAdapter.Fill(MyDS, "T_Dogs")
Dim rptDoc As New CrystalDecisions.CrystalReports.Engine.ReportDocument()
rptDoc.SetDataSource(MyDS)

rptDoc.Load(Server.MapPath("~\Account\Reports\CrystalReport1.rpt"))
CrystalReportViewer1.ReportSource = rptDoc

Catch ex As Exception
Throw ex
Finally
comm.Dispose()
Conn.Dispose()
End Try

End Sub

I problemi che si presentano sono:
1) percorso del Report non valido: le ho provate tutte, dando D:\\ ..... , togliendo la tilde, togliendo tutto e dando solo il nome del report.
2) quando per puro caso mi accetta il percorso, mi apre la pagina Reports, però al posto del Viewer compare la scritta "Errore nel caricamento del Report". Se cambio qualcosa, torno al punto 1) e comincia a darmi nuovamente l'errore del percorso.

Ho tentato sia tramite il code Behind, che seguendo l'inserimento del Viewer in progettazione, anche creando il report di sana pianta. Mi da comunque l'errore del punto 2)

Dove sbaglio?

Grazie a tutti!
Barbara

freeteo Profilo | Guru

Ciao Barbara,
forse avrai già risolto visto che è passato un bel po' di tempo, ad ogni modo, ti segnalo questo link che potrebbe tornarti utile:
http://www.dotnethell.it/articles/Crystal-Reports-Integration-Windows-Form.aspx

a fondo pagina trovi anche i sorgenti.

Ciao.

Matteo Raumer
[MCAD .net, MVP Visual C#]
http://blogs.dotnethell.it/freeteo
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5