p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

crystal_reports thread: Report with Subreport using ADO.NET Error


Message #1 by "Dan Slaby" <DSlaby@E...> on Tue, 4 Feb 2003 19:07:40 -0800
Here is my code to run a report with a subreport. I get the error
message when I set the report source:
 
A first chance exception of type 'System.TypeLoadException' occurred in
crdb_adoplus.dll
 
Additional information: Could not load type SCCData from assembly
crdb_adoplus, Version=9.1.3300.0, Culture=neutral,
PublicKeyToken=692fbea5521e1304.
 
CODE:
 
Imports System.Data.SqlClient
Imports System.Data
Imports CrystalDecisions.Shared
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Windows.Forms
 
Public Class frmRCViewer
    Inherits System.Windows.Forms.Form
 
#Region " Windows Form Designer generated code "
 
    Public Sub New()
        MyBase.New()
 
        'This call is required by the Windows Form Designer.
        InitializeComponent()
 
    End Sub
 
    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As
Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub
 
    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer
 
    'NOTE: The following procedure is required by the Windows Form
Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents crViewer As
CrystalDecisions.Windows.Forms.CrystalReportViewer
    Friend WithEvents sqlCN As System.Data.SqlClient.SqlConnection
    <System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
        Me.crViewer = New
CrystalDecisions.Windows.Forms.CrystalReportViewer()
        Me.sqlCN = New System.Data.SqlClient.SqlConnection()
        Me.SuspendLayout()
        '
        'crViewer
        '
        Me.crViewer.ActiveViewIndex = -1
        Me.crViewer.Dock = System.Windows.Forms.DockStyle.Fill
        Me.crViewer.Name = "crViewer"
        Me.crViewer.ReportSource = Nothing
        Me.crViewer.Size = New System.Drawing.Size(584, 382)
        Me.crViewer.TabIndex = 0
        '
        'sqlCN
        '
        Me.sqlCN.ConnectionString = "data source=DSHSFLMNI03;initial
catalog=SCCData;password=$Quimo123;persist securi" & _
        "ty info=True;user id=SCCUser;workstation id=C1798841-A;packet
size=4096"
        '
        'frmRCViewer
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(584, 382)
        Me.Controls.AddRange(New System.Windows.Forms.Control()
{Me.crViewer})
        Me.Name = "frmRCViewer"
        Me.Text = "frmRCViewer"
        Me.WindowState = System.Windows.Forms.FormWindowState.Maximized
        Me.ResumeLayout(False)
 
    End Sub
 
#End Region
 
    Dim crCard As New crResidentCard()
    Dim crSections As Sections
    Dim crSection As Section
    Dim crReportObjects As ReportObjects
    Dim crReportObject As ReportObject
    Dim crSubReportObject As SubreportObject
    Dim crSubReportDocument As ReportDocument
 
    Dim crDB As Database
    Dim crTables As Tables
    Dim crTable As Table
    Dim crTableLogOnInfos As TableLogOnInfos
    Dim crTableLogOnInfo As TableLogOnInfo
    Dim crCNInfo As New ConnectionInfo()
 
    Dim da As New SqlDataAdapter()
    Dim residentCardDS As New DataSet()
    Dim residentProblemsDS As New DataSet()
 
    Dim cmd As New SqlCommand()
    Dim sCard As String = "sp_ResidentCard"
    Dim sProb As String = "sp_ResidentProblems"
 
    Private Sub frmCRViewer_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
 
        Me.Cursor = Cursors.WaitCursor
 
        Try
            If Not sqlCN.State = ConnectionState.Open Then sqlCN.Open()
            cmd.Connection = sqlCN
            cmd.CommandText = sCard
            cmd.CommandType = CommandType.StoredProcedure
            da.SelectCommand = cmd
            da.Fill(residentCardDS, sCard)
 
            cmd.CommandText = sProb
            cmd.CommandType = CommandType.StoredProcedure
            da.SelectCommand = cmd
            da.Fill(residentProblemsDS, sProb)
 
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        Finally
            If Not sqlCN.State = ConnectionState.Closed Then
sqlCN.Close()
            da.Dispose()
            cmd.Dispose()
        End Try
 
 
        crDB = crCard.Database
        crTables = crDB.Tables
 
        With crCNInfo
            .ServerName = "DSHSFLMNI03"
            .UserID = "SCCUser"
            .Password = "$Quimo123"
            .DatabaseName = "SCCData"
        End With
 
        For Each crTable In crTables
            crTableLogOnInfo = crTable.LogOnInfo
            crTableLogOnInfo.ConnectionInfo = crCNInfo
            crTable.ApplyLogOnInfo(crTableLogOnInfo)
            crTableLogOnInfos.Add(crTableLogOnInfo) <<-- Error Message
line
        Next
 
        crSections = crCard.ReportDefinition.Sections()
        For Each crSection In crSections
            crReportObjects = crSection.ReportObjects
            For Each crReportObject In crReportObjects
                If crReportObject.Kind 
ReportObjectKind.SubreportObject Then
                    crSubReportObject = CType(crReportObject,
SubreportObject)
                    crSubReportDocument 
crSubReportObject.OpenSubreport(crSubReportObject.SubreportName)
                End If
            Next
        Next
 
        crDB = crSubReportDocument.Database
        crTables = crDB.Tables
 
        For Each crTable In crTables
            crTableLogOnInfo = crTable.LogOnInfo
            crTableLogOnInfo.ConnectionInfo = crCNInfo
            crTable.ApplyLogOnInfo(crTableLogOnInfo)
        Next
 
        crViewer.SetBounds(0, 0, Me.ClientSize.Width,
Me.ClientSize.Height)
        crViewer.DisplayToolbar = True
        crViewer.DisplayGroupTree = True
        crViewer.LogOnInfo = crTableLogOnInfos
        crViewer.ReportSource = crCard
        Me.Cursor = Cursors.Default
    End Sub
 
End Class
 
******************
Exception message:
 
A first chance exception of type 'System.NullReferenceException'
occurred in sccMed.exe
 
Additional information: Object reference not set to an instance of an
object.
 
******************
Exception message:
 
A first chance exception of type 'System.TypeLoadException' occurred in
crdb_adoplus.dll
 
Additional information: Could not load type SCCData from assembly
crdb_adoplus, Version=9.1.3300.0, Culture=neutral,
PublicKeyToken=692fbea5521e1304.
 
Evergreen Information Systems, LLC
1435 Elm ST SE
Auburn, WA 98092
(xxx) xxx-xxxx
 


  Return to Index