CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2006
    Posts
    2

    Unhappy Crystal Reports: How to change Oracle OLE DB server at runtime?

    I'm using a rpt made with Crystal Reports 8.0.1 and VB 6. The report was made using the Microsoft OLE DB provider for Oracle. What I want

    to do is change to Oracle server / database the report is connecting to at run time before the report is displayed. I am using

    the Crystal Report Engine 8 Object Library (cpeaut32.dll), not the ocx.

    After creating the report object:

    Dim CrystalReport As CRPEAuto.Report

    I open my report and discard saved data:

    'Open The Report
    Set CrystalReport = CrystalApplication.OpenReport(msReportSource)
    CrystalReport.DiscardSavedData

    Const sDBServer = "ORCL.SERVER" 'My TNS name for the Oracle Server
    Const sDatabase = "ORCL.SERVER" 'I'm not sure what this value should be
    Const sUID = "system"
    Const sPwd = "manager"

    I was then going to change the database connection one of two ways:

    1:
    Dim objDatabaseTable As CRPEAuto.DatabaseTable
    For Each objDatabaseTable In CrystalReport.Database.Tables
    Call objDatabaseTable.SetLogOnInfo(sDBServer, sDATABASE, sUID, sPWD)
    If (Not objDatabaseTable.TestConnectivity) Then
    Debug.Print "Database failed connection: " & objDatabaseTable.Name
    End If
    Next
    Set objDatabaseTable = Nothing

    2:
    call crystalapplication.LogOnServer("pdsoledb.dll","MSDAORA.1",sDATABASE,sUID,sPWD)


    Neither of these two way gets me a successful connection. What am I doing wrong, and which is the preferred method to use?


    Thanks

    Dean

  2. #2
    Join Date
    Jul 2008
    Posts
    6

    Re: Crystal Reports: How to change Oracle OLE DB server at runtime?

    With crConnectionInfo
    .ServerName = "YOUR SERVER NAME"
    .DatabaseName = "YOUR DATABASE NAME"
    .UserID = "YOUR DATABASE USERNAME"
    .Password = "YOUR DATABASE PASSWORD"
    End With

    CrTables = cryRpt.Database.Tables
    For Each CrTable In CrTables
    crtableLogoninfo = CrTable.LogOnInfo
    crtableLogoninfo.ConnectionInfo = crConnectionInfo
    CrTable.ApplyLogOnInfo(crtableLogoninfo)
    Next


    source code url

    http://vb.net-informations.com/cryst...ynamically.htm

    suzett.

  3. #3
    Join Date
    Jul 2005
    Posts
    1,083

    Re: Crystal Reports: How to change Oracle OLE DB server at runtime?

    I think that suzett is a fan of Cold Case tv serie

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

Featured