Question : Need help with Crystal Report and Visual Studio

I am trying to get my first Crystal Report working under Visual Studio 2008. Please note I am NOT using SQL Server.   The problem is the report is coming up blank. I THINK it's a parameter problem but I am not sure.  This is what I have done:    First I added a dataset with a data adapter under App_code.  It's called hardcard.xsd.  It calls a mainframe DB2 stored procedure. When I click on Preview Data and give it a parameter it calls up the correct data.  So I know that part is working correctly. The parameter is called Prmt_ID.

Then I created a report using the Crystal Report wizard under Visual Studio. I used the previous dataset as the datasource.  The wizard listed it as one of the available Data Sources under Project Data.  The report is named BuildingPermt.rpt and is located under a folder called Permits.  I added a Parameter Field via Field Explorer and called it Prmt_ID.

Under the same folder as the report I added a web form and called it BuildingPermit.aspx.  I added a CrystalReportViewer. Here is the code:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
<%@ Page Language="VB" MasterPageFile="~/MasterPages/MasterPagePermit.master" AutoEventWireup="false" CodeFile="BuildingPermit.aspx.vb" Inherits="Permits_BuildingPermit" title="Untitled Page" %>

<%@ Register Assembly="CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
    Namespace="CrystalDecisions.Web" TagPrefix="CR" %>

<asp:Content ID="Content1" ContentPlaceHolderID="PermitContent" Runat="Server">

<CR:CrystalReportViewer ID="myCrystalReportViewer" runat="server" 
        Height="50px" 
        Width="350px" />
               
  </asp:Content>


 This is the code that I have put in the code behind. I have blocked out my userid info for this post.

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
Option Strict On
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports IBM.Data.DB2
Imports System.Data

Partial Class Permits_BuildingPermit
    Inherits System.Web.UI.Page

    Private BuildingPermit As ReportDocument


    Private Sub ConfigureCrystalReports()
        BuildingPermit = New ReportDocument()
        BuildingPermit.Load("C:\Visual Studio 2008\WebSites\LandMgmt\permits\BuildingPermt.rpt")
        BuildingPermit.SetDataSource("LMIST")
        BuildingPermit.SetParameterValue("PRMT_ID", 192174)
        myCrystalReportViewer.ReportSource = BuildingPermit
        BuildingPermit.SetDatabaseLogon("xxxxxx, "xxxxxx")  
        Page.DataBind()
    End Sub

    Private Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init

        ConfigureCrystalReports()

    End Sub
End Class


I worked through a lot of connection issues and at this point I am not getting any error messages. The Report viewer controls are displaying and the Report Parameter is showing but nothing else.  I tried to add a row selection for the table field to match the parameter but it says there is no such table field.    I've tried given it a default value to see if that would make data appear but that hasn't helped either.   Do I need to add some kind of code for the dataadapter? I've been messing around with this thing for weeks and my bosses are getting impatient. Help!  

Answer : Need help with Crystal Report and Visual Studio

Please only use this code don't use setdatasource:
Public Sub configuracrystalReports()
        Dim BuildingPermit As New ReportDocument()
        Dim reportpath As String = "C:\Visual Studio 2008\WebSites\LandMgmt\permits\BuildingPermt.rpt"
        BuildingPermit.Load(reportpath)

        Dim mytable As New App_Code/Hardcard.HardcardDataTable
        Dim myadapter As New App_Code/HardcardTableAdapters.HARDCARDTableAdapter

        myadapter.Fill(mytable, 192174)
        BuildingPermit.SetDatabaseLogon("yourusername", "yourpassword")
        BuildingPermit.SetDataSource(DirectCast(mytable, DataTable))

        myCrystalReportViewer.ReportSource = BuildingPermit

    End Sub

Don't import your table/tableadapters.  You need to figure out the correct naming for them you should see them using intellisense. They should be there for you.
You need to use fill.
I don't know why yours have App_Code before the dataset name. I wonder if the issue is how you created it.
Random Solutions  
 
programming4us programming4us