Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
| Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics 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 October 16th, 2006, 01:04 AM
Authorized User
 
Join Date: May 2006
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default Failed to Load Database Information in Crystal Rep


hi guys ,
we are using Crystal report for windows Application.when i get repot folling error Appears guide me.............

Failed to Load DataBase Information


Imports CrystalDecisions.Shared
Imports CrystalDecisions.CrystalReports.Engine
Imports System.Data
Imports System.Windows.Forms
Public Class frmReport
    Inherits System.Windows.Forms.Form
    Dim Criteria As String
    Dim ReportName As String
    Private ReportDataSet As DataSet
    Private strParamName() As String
    Private strParamValue() As String

    Dim crParameterFieldDefinitions As ParameterFieldDefinitions
    Dim crParameterFieldDefinition As ParameterFieldDefinition

    'ParameterValues and ParameterDiscreteValue are off the CrystalDecisions.Shared
    'namespace
    Dim crParameterValues As New ParameterValues
    Dim crParameterDiscreteValue As New ParameterDiscreteValue
#Region " Windows Form Designer generated code "
    Public Sub New(ByVal WhereClause As String, ByVal Rname As String, _
    Optional ByVal Ds As DataSet = Nothing, Optional ByVal ParamName() As String = Nothing, _
    Optional ByVal ParamValue() As String = Nothing)
        MyBase.New()
        Criteria = WhereClause
        ReportName = Rname
        ReportDataSet = Ds
        strParamName = ParamName
        strParamValue = ParamValue
        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    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 rpt As CrystalDecisions.Windows.Forms.CrystalReportViewer
    Friend WithEvents Button1 As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.rpt = New CrystalDecisions.Windows.Forms.CrystalReportViewer
        Me.Button1 = New System.Windows.Forms.Button
        Me.SuspendLayout()
        '
        'rpt
        '
        Me.rpt.ActiveViewIndex = -1
        Me.rpt.DisplayBackgroundEdge = False
        Me.rpt.DisplayGroupTree = False
        Me.rpt.Dock = System.Windows.Forms.DockStyle.Fill
        Me.rpt.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.rpt.Location = New System.Drawing.Point(0, 0)
        Me.rpt.Name = "rpt"
        Me.rpt.ReportSource = Nothing
        Me.rpt.Size = New System.Drawing.Size(982, 531)
        Me.rpt.TabIndex = 0
        '
        'Button1
        '
        Me.Button1.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Button1.Location = New System.Drawing.Point(0, 0)
        Me.Button1.Name = "Button1"
        Me.Button1.TabIndex = 1
        Me.Button1.TabStop = False
        Me.Button1.Text = "Button1"
        '
        'frmReport
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.CancelButton = Me.Button1
        Me.ClientSize = New System.Drawing.Size(982, 531)
        Me.Controls.Add(Me.rpt)
        Me.Controls.Add(Me.Button1)
        Me.Name = "frmReport"
        Me.Text = "frmReport"
        Me.WindowState = System.Windows.Forms.FormWindowState.Maximized
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub frmReport_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim crtableLogoninfos As New TableLogOnInfos
        Dim crtableLogoninfo As New TableLogOnInfo
        Dim crConnectionInfo As New ConnectionInfo
        Dim CrTables As Tables
        Dim CrTable As Table
        Dim TableCounter
        Dim crReportDocument As New ReportDocument
        Dim NameCount As Integer
        Dim ValueCount As Integer

        winPlsWait = New frmStatus
        winPlsWait.Show("Generating report....")

        crReportDocument.Load(ReportName)
        If Not strParamName Is Nothing Then
            While NameCount <> strParamName.Length
                crParameterDiscreteValue.Value = strParamValue.GetValue(NameCount).ToString
                crParameterFieldDefinitions = crReportDocument.DataDefinition.ParameterFields
                crParameterFieldDefinition = crParameterFieldDefinitions.Item(strParamName.GetV alue(NameCount).ToString)
                crParameterValues = crParameterFieldDefinition.CurrentValues
                crParameterValues.Clear()
                crParameterValues.Add(crParameterDiscreteValue)
                crParameterFieldDefinition.ApplyCurrentValues(crPa rameterValues)
                NameCount = NameCount + 1
            End While
        End If

        With crConnectionInfo
            .ServerName = Configuration.ConfigurationSettings.AppSettings("s name")
            .DatabaseName = Configuration.ConfigurationSettings.AppSettings("d name")
            .UserID = "sa"
            .Password = "manager"
        End With
        CrTables = crReportDocument.Database.Tables
        For Each CrTable In CrTables
            crtableLogoninfo = CrTable.LogOnInfo
            crtableLogoninfo.ConnectionInfo = crConnectionInfo
            CrTable.ApplyLogOnInfo(crtableLogoninfo)
        Next

        '''------------Subreport Database Logon Info
        Dim mySubRepDoc As New CrystalDecisions.CrystalReports.Engine.ReportDocum ent
        Dim mySubReportObject As CrystalDecisions.CrystalReports.Engine.SubreportOb ject
        Dim index As Integer
        Dim intCounter, intCounter1 As Integer
        For index = 0 To crReportDocument.ReportDefinition.Sections.Count - 1

            For intCounter = 0 To crReportDocument.ReportDefinition.Sections(index). ReportObjects.Count - 1
                With crReportDocument.ReportDefinition.Sections(index)
                    If .ReportObjects(intCounter).Kind = CrystalDecisions.Shared.ReportObjectKind.Subreport Object Then
                        mySubReportObject = CType(.ReportObjects(intCounter), CrystalDecisions.CrystalReports.Engine.SubreportOb ject)
                        mySubRepDoc = mySubReportObject.OpenSubreport(mySubReportObject. SubreportName)
                        Dim CrTables1 As Tables
                        Dim CrTable1 As Table
                        CrTables1 = mySubRepDoc.Database.Tables
                        For Each CrTable1 In CrTables1
                            crtableLogoninfo = CrTable1.LogOnInfo
                            crtableLogoninfo.ConnectionInfo = crConnectionInfo
                            CrTable1.ApplyLogOnInfo(crtableLogoninfo)
                        Next
                    End If
                End With
            Next
        Next
        '''------------------End

        If ReportDataSet Is Nothing Then
            rpt.ReportSource = crReportDocument
            rpt.SelectionFormula = Criteria
        Else
            rpt.ReportSource = crReportDocument
            crReportDocument.SetDataSource(ReportDataSet.Table s(0))
            crReportDocument.SetDatabaseLogon("SA", "manager", Configuration.ConfigurationSettings. _
            AppSettings("sname"), Configuration.ConfigurationSettings.AppSettings("d name"))
            rpt.ReportSource = crReportDocument
            rpt.SelectionFormula = ""
        End If
        winPlsWait = Nothing
        rpt.RefreshReport()
        rpt.Show()

    End Sub





Similar Threads
Thread Thread Starter Forum Replies Last Post
Load of Report failed --vb.net 2003, Crystal repor avats Crystal Reports 0 October 23rd, 2005 01:19 PM
crystal rep printing problems in win NT nilesh_parmar Crystal Reports 0 December 21st, 2004 05:57 AM
Failed to load database information r_ganesh76 Crystal Reports 4 October 7th, 2004 03:04 AM
Save Crystal Rep with out data pavel Pro VB 6 2 March 3rd, 2004 07:26 AM
C#how to pass string to crystal and show it in rep salmaan Crystal Reports 0 September 11th, 2003 02:55 PM





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