• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 484
  • Last Modified:

.vb class file not created for crystal report in asp.net 2005

I am having problems figuring this out.  I am trying to do an automatic login in a crystal report using asp.net 2005.  From a previous post I got the code to do this.

The problem I seem to be having is that VS 2005 doesn't seem to be creating the .vb file under the .rpt report file.  Because of this I can create a new variable for the strongly instantiated report.  Example:

My report is called PalletLogReport.rpt
The asp.net page is called PalletLog.aspx
In the .vb code under the .aspx I have the following:

Dim crReportDocument As PalletLogReport()

The compiler then tells me that PalletLogReport is not defined.

What is happening here?  This is happening in VS 2005, does VS not create these files anymore in 2005?  

0
sbhegel
Asked:
sbhegel
  • 4
  • 2
1 Solution
 
mlmccCommented:
Did you build the dsr for the report?  To get the class, I believe you have to "import" the report into your application.

mlmcc
0
 
dylanyeeCommented:
I am not sure about VS2005, but from VS2003, if I right click the .rpt file and click "Run Custom Tool", it will generate the .vb file for you.

dylan
0
 
sbhegelAuthor Commented:
mlmcc,

What is the dsr?  And what do you mean by import?  I have made a copy of this file, deleted the original and then did and add existing item.  That still doesn't work.



0
New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

 
sbhegelAuthor Commented:
dylanyee,

I don't see a Run Custom Tool option when I right click the .rpt file.  Is there another way to access this?
0
 
dylanyeeCommented:
I am not sure about VS 2005, but in VS 2003 there is such option once I right click on the .rpt file.
Other than implement the report using strongly instantiated, could you try other method such as

Import CrystalDecision.ReportEngine
Import CrystalDecision.Shared
....
Dim crReport = new ReportDocument()
crReport.Load("Your rpt...")

It will be more flexible than using strongly instantiated, because you don't have to pre-generate a report class for each report.

dylan
0
 
sbhegelAuthor Commented:
OK,

I am totally confused now.  Here is the code I have in the web page that has the CR viewer in it.   This is in the Page_load procedure:

        CrystalReportSource1.DataBind()
 
        Dim crReportDocument As New ReportDocument()        
        crReportDocument.Load("D:\fullpathtofile\PalletLogReport.rpt")
 
        Dim crTableLogonInfos As TableLogOnInfos
        Dim crTableLogonInfo As TableLogOnInfo
        Dim crConnectionInfo As ConnectionInfo
       
        ' crReportDocument = New PalletLogReport()
        crTableLogonInfos = New TableLogOnInfos()
        crTableLogonInfo = New TableLogOnInfo()

        crConnectionInfo = New ConnectionInfo()
        With crConnectionInfo
            .ServerName = "myserver"
            .DatabaseName = "mydb"
            .UserID = "myuser"
            .Password = "mypassword"
        End With

        crTableLogonInfo.ConnectionInfo = crConnectionInfo
        crTableLogonInfo.TableName = "PalletLabel"
        crTableLogonInfos.Add(crTableLogonInfo)

        CrystalReportViewer1.LogOnInfo = crTableLogonInfos
        CrystalReportViewer1.ReportSource = crReportDocument

What is incorrect about this?
0
 
sbhegelAuthor Commented:
I figured this one out.  The reason the .vb file is not created for the .rpt file in VS 2005 is because:

In Visual Studio 2005, Crystal Reports report files are no longer embedded in Web projects; therefore, no report wrapper class is generated. The reports are stored in a folder and, as with all non-embedded reports, they must be referenced by their file directory path. In this case, the directory path is to the current Web Site folder.

However, Windows projects in Visual Studio 2005 remain unchanged from earlier Visual Studio versions; they continue to use embedded reports.


Also the code I listed above didn't automatically login but the code below does:

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared

Dim crDatabase As Database
Dim crTables As Tables
Dim crTable As Table
Dim  crTableLogOnInfo As TableLogOnInfo
Dim crConnectionInfo As ConnectionInfo

CrConnectionInfo = New ConnectionInfo()
With crConnectionInfo
      .DatabaseName = “database”
      .Password = “password”
      .ServerName = “servername”
      .UserID = “user id”
End With

CrDatabase = report.Database
CrTables = crDatabase.Tables

For Each crTable in crTables
      CrTableLogOnInfo = crTable.LogOnInfo
      CrTableLogOnInfo.ConnectionInfo = crConnectionInfo
      CrTable.ApplyLogOnInfo(crTableLogOnInfo)
Next

CrystalReportViewer1.ReportSource = report


The difference is one was logging into the view and this code is passing the logon information to the report.

I don't know the best way to give out the points on this, so if the moderator could lend there knowledge, I would appreciate it.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now