Results 1 to 3 of 3

Thread: Connection Info

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2001
    Posts
    79

    Connection Info

    I am working on a project where I need to pass connection info to a report at runtime, I am using VS.Net with integrated Crystal Reports. It seems that the only parameters possible are :-

    DataBaseName
    ServerName
    Password
    UserID

    From test it seems that the only way I could pass parameters is that these are through ODBC and must have the same DSN as the original report design. where

    Databasename = DSN
    ServerName= DSN
    Password = PW
    UserID =PW

    Currently I have the following routine.

    connInfo is a shared class holding Databasename, Servername, password and UserId which I am entering at runtime.

    crTables is a collection of the tables in the report.

    For Each crTable In crTables
    crTableLogOnInfo = crTable.LogOnInfo
    crTableLogOnInfo.ConnectionInfo = ConnInfo
    crTable.ApplyLogOnInfo(crTableLogOnInfo)
    Next


    Altough there is documention "cr_rdc9_connectionproperties.pdf" on crystal decisions site it seems that this is not valid for crystal reports integrated with VS.net.

    At minimum I need to conenct to MS-SQL, Access and Oracle by providing runtime values.

    I appreciate some help on what options there are for the connectioninfo properties to be set at runtime.
    Last edited by TonySaliba; Nov 9th, 2003 at 07:09 AM.

  2. #2
    New Member
    Join Date
    Nov 2003
    Location
    NA
    Posts
    5
    '***************************************************************************
    'This Visual Basic .NET sample Windows application demonstrates how to
    'set database logon information for a report based on a secured datasource.
    '***************************************************************************



    ''Both of these CR assemblies are required to be able to
    ''access, load, and set database logon.
    Imports CrystalDecisions.CrystalReports.Engine
    Imports CrystalDecisions.Shared

    Public Class Form1
    Inherits System.Windows.Forms.Form

    ''CR Variables
    Dim crReportDocument As CrystalReport1
    Dim crDatabase As Database
    Dim crTables As Tables
    Dim crTable As Table
    Dim crTableLogOnInfo As TableLogOnInfo
    Dim crConnectionInfo As ConnectionInfo

    #Region " Windows Form Designer generated code "

    Public Sub New()
    MyBase.New()

    'This call is required by the Windows Form Designer.
    InitializeComponent()

    'Add any initialization after the InitializeComponent() call

    'Create an instance of the strongly-typed report object
    crReportDocument = New CrystalReport1()

    'Setup the connection information structure to be used
    'to log onto the datasource for the report.
    crConnectionInfo = New ConnectionInfo()
    With crConnectionInfo
    .ServerName = "escalade" 'physical server name
    .DatabaseName = "Pubs"
    .UserID = "sa"
    .Password = "admin"
    End With

    'Get the table information from the report
    crDatabase = crReportDocument.Database
    crTables = crDatabase.Tables

    'Loop through all tables in the report and apply the connection
    'information for each table.
    For Each crTable In crTables
    crTableLogOnInfo = crTable.LogOnInfo
    crTableLogOnInfo.ConnectionInfo = crConnectionInfo
    crTable.ApplyLogOnInfo(crTableLogOnInfo)
    Next

    'Set the viewer to the report object to be previewed.
    CrystalReportViewer1.ReportSource = crReportDocument

    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
    Friend WithEvents CrystalReportViewer1 As CrystalDecisions.Windows.Forms.CrystalReportViewer

    '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.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    Me.CrystalReportViewer1 = New CrystalDecisions.Windows.Forms.CrystalReportViewer()
    Me.SuspendLayout()
    '
    'CrystalReportViewer1
    '
    Me.CrystalReportViewer1.ActiveViewIndex = -1
    Me.CrystalReportViewer1.Dock = System.Windows.Forms.DockStyle.Fill
    Me.CrystalReportViewer1.Name = "CrystalReportViewer1"
    Me.CrystalReportViewer1.ReportSource = Nothing
    Me.CrystalReportViewer1.Size = New System.Drawing.Size(584, 413)
    Me.CrystalReportViewer1.TabIndex = 0
    '
    'Form1
    '
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(584, 413)
    Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.CrystalReportViewer1})
    Me.Name = "Form1"
    Me.Text = "Form1"
    Me.ResumeLayout(False)

    End Sub

    #End Region

    End Class

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2001
    Posts
    79
    Thanks for the reply, another few questions:-

    Do you require MS-SQL server cleint components to be installed on the client.

    Also if I have a remote Access Database what ist he best way to connect. I already tried putting the path to the database but I get a login screen everytime I run the report. The access database is PW protected but I am passing the PW also as parameter.

    Everything works if I use ODBC.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width