Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > Crystal Reports
|
Crystal Reports General discussion about Crystal Reports. For discussions specific to the book Professional Crystal Reports for VS.NET, please see the book discussion forum for that book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Crystal Reports section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 26th, 2003, 10:43 AM
Registered User
 
Join Date: Jun 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Asp.net and “Pushed” Crystal Reports In 3 tier Arc


Environment: Microsoft Visual Studio Net
        Microsoft .NET framework 1.0
        Microsoft .NET framework 1.0
                        SQL Server 2000
                        Windows 2000 Pro
                         IIS Personal Web Server

I am having the dickens of a time generating a crystal report using a push method. The report (cfrEmp) exists in the .net solution as well as the dataset schema. I am using the following code to retrieve data from a stored procedure in a SQL database. I then use a dataadapter to populate a dataset (cfrEmpAll) which then becomes the datasource for the crystal report. The stored proc has set no counts on and has no parameters. The report will generate with field labels and report heading, but no data. Like the dataset is not populating. Anyone have any thoughts???

Thanks

-Paul

Code Follows:
Imports System.Data
Imports System.Data.SqlClient
Imports System.Security

Public Class cfrAllEmpForm
    Inherits System.Web.UI.Page
    Protected WithEvents CrystalReportViewer2 As CrystalDecisions.Web.CrystalReportViewer

#Region " Web Form Designer Generated Code "

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim MyConnection As SqlConnection
        Dim MyAdapter As SqlDataAdapter
        Dim MyStoredProc As SqlCommand
        Dim MyData As DataSet
        Dim oRpt As New cfrEmp()

        ' Connection
        Dim strCon As String

        '
        strCon = "Server=****; Trusted_Connection=yes; uid=gvldataload; pwd=********; Integrated Security=True; Database=****;"
        MyConnection = New SqlConnection(strCon)

        ' select command
        MyStoredProc = New SqlCommand()
        MyStoredProc.Connection = MyConnection
        MyStoredProc.CommandType = CommandType.StoredProcedure
        MyStoredProc.CommandText = "cfrLevelAll_sps"

        'DataAdapter
        MyAdapter = New SqlDataAdapter()
        MyAdapter.SelectCommand = MyStoredProc

        ' DataSet
        MyData = New cfrEmpAll()

        MyAdapter.Fill(MyData)
        'oRpt.Load()
        oRpt.SetDataSource(MyData)
        CrystalReportViewer2.ReportSource = oRpt
        CrystalReportViewer2.DataBind()

    End Sub

End Class
 
Old June 27th, 2003, 12:48 PM
Registered User
 
Join Date: Jun 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have successfully used strongly-typed datasets as datasources for Crystal reports. Like you, I used stored procedures to access data through dataAdapters for each typed dataset. Although it probably makes no difference, I also used the TableMapping object auto-generated by the Visual Studio dataAdapter wizard. If you set a breakpoint at MyAdapter.Fill(MyData) you could determine, for example by examining the dataset in the Locals window, whether the data you expected is in the dataset. This will tell you whether the problem lies in your data access or Crystal Reports-related code. (In case you're not familiar with this, select Debug -- Processes, then attach the asp.net worker process to initiate debugging.)
 
Old July 2nd, 2003, 11:42 AM
Registered User
 
Join Date: Jul 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I think if you change the last part of your code as follows it will work:

oRpt.Load("path + fileName of your .rpt file")
oRpt.SetDataSource(MyData.Tables(0))
CrystalReportViewer2.ReportSource = oRpt
'CrystalReportViewer2.DataBind() -> you don't have to do that
 
Old July 2nd, 2003, 11:57 AM
Registered User
 
Join Date: Jul 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry I made a mistake :D It should be like this:

oRpt.Load()
oRpt.SetDataSource(MyData.Tables(0))
CrystalReportViewer2.ReportSource = oRpt

Quote:
quote:Originally posted by gokce
 I think if you change the last part of your code as follows it will work:

oRpt.Load("path + fileName of your .rpt file")
oRpt.SetDataSource(MyData.Tables(0))
CrystalReportViewer2.ReportSource = oRpt
'CrystalReportViewer2.DataBind() -> you don't have to do that




 
Old November 9th, 2004, 10:41 PM
Authorized User
 
Join Date: Sep 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to zouky
Default

i got a bit confusion on the declaration on Dim oRpt As New cfrEmp()
where's the origin class for this?


 
Old November 9th, 2004, 10:41 PM
Authorized User
 
Join Date: Sep 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to zouky
Default

i got a bit confusion on the declaration on Dim oRpt As New cfrEmp()
where's the origin class for this?







Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.NET 1.1,VB.NET,crystal reports, SQl server gvi Crystal Reports 1 September 11th, 2008 02:55 AM
Crystal Reports in asp.net 1.1 Pramods ASP.NET 1.0 and 1.1 Professional 0 June 14th, 2007 08:27 AM
ASP.NET - Crystal Reports venkat999 ASP.NET 2.0 Professional 2 October 29th, 2006 09:39 AM
Using Crystal Reports in ASP.NET jbenson001 ASP.NET 1.x and 2.0 Application Design 2 November 18th, 2003 10:52 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.