Results 1 to 9 of 9

Thread: ** RESOLVED ** [2005] BO XI R2 db connection issue

  1. #1

    Thread Starter
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    ** RESOLVED ** [2005] BO XI R2 db connection issue

    I am having a problem trying to figure out how to have a report connect to two databases. I have one db that contains tooling data, but I also need to connect to another db that has product description data. I thought I might be able to do this:
    VB Code:
    1. Case "Z:\Tooling\Xref.rpt"
    2.                 ReportPath = Application.StartupPath & "\Xref.rpt"
    3.                 CRViewer1.ReportSource = ReportPath
    4.                 Dim myTableLogOnInfos As TableLogOnInfos = CRViewer1.LogOnInfo
    5.  
    6.                 For Each myTableLogOnInfo As TableLogOnInfo In myTableLogOnInfos
    7.                     If report.name = "Unprinted" Then
    8.                         myTableLogOnInfo.ConnectionInfo = myConnecionInfo2
    9.                     Else
    10.                         myTableLogOnInfo.ConnectionInfo = myConnecionInfo
    11.                     End If
    12.                 Next

    That does nto seem to be working. I can't seem to find out how to determine the table name that it is trying to cvonnect to. Also, it is telling me that myConnectionInfo & myConnectionInfo2 are not defined. Yet at the top of the subroutine I have:

    VB Code:
    1. Dim myConnectionInfo As ConnectionInfo
    2.         Dim myConnectionInfo2 As ConnectionInfo
    3.         Dim ReportPath As String
    4.         Dim mySelectionFormula As String = ""
    5.         myConnectionInfo = New ConnectionInfo
    6.         With myConnectionInfo
    7.             .ServerName = "Primero"
    8.             .DatabaseName = "Tooling"
    9.             .UserID = "sa"
    10.             .Password = myPasswordTechniSQL
    11.         End With
    12.         With myConnectionInfo2
    13.             .ServerName = "Primero"
    14.             .DatabaseName = "Techni"
    15.             .UserID = "sa"
    16.             .Password = myPasswordTechniSQL
    17.         End With
    Last edited by Pasvorto; Nov 21st, 2006 at 10:55 AM.

  2. #2
    Fanatic Member
    Join Date
    Aug 2006
    Location
    Chicago, IL
    Posts
    514

    Re: [2005] BO XI R2 db connection issue

    Are you assigning back to the viewer the logon info?
    Warren Ayen
    Senior C# Developer
    DLS Software Studios (http://www.dlssoftwarestudios.com/)

    I use Microsoft Visual Studio 2005, 2008, working with Visual Basic and Visual C#
    Hey! If you like my post, or I solve your issue, please Rate Me!

  3. #3

    Thread Starter
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: [2005] BO XI R2 db connection issue

    I guess I don't understand what you mean.

  4. #4
    Fanatic Member
    Join Date
    Aug 2006
    Location
    Chicago, IL
    Posts
    514

    Re: [2005] BO XI R2 db connection issue

    Well I see you're creating logon info, but I don't see you assigning that logon object back to the viewer so it can use it. I just see you creating it.

    I'm not seeing:
    VB Code:
    1. CRViewer1.LogOnInfo = myTableLogOnInfo
    Warren Ayen
    Senior C# Developer
    DLS Software Studios (http://www.dlssoftwarestudios.com/)

    I use Microsoft Visual Studio 2005, 2008, working with Visual Basic and Visual C#
    Hey! If you like my post, or I solve your issue, please Rate Me!

  5. #5

    Thread Starter
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: [2005] BO XI R2 db connection issue

    Well, it's getting wierder by the minute...

    I run the program (in the IDE) and run the report. It runs fine. I run it again (going back to the reports menu) and I get the "Load Report Failed" error and have to log on again. If I stop the program and restart it, I get the same error. Now, the weird part... If I stop the program and wait a couple minutes and restart it, the report runs just fine. Is this a 'garbage collection' thing?

  6. #6
    Fanatic Member
    Join Date
    Aug 2006
    Location
    Chicago, IL
    Posts
    514

    Re: [2005] BO XI R2 db connection issue

    I had the same error, before. I remember that.

    I have no issues now, and I never figured out what caused it. All I know is my code works perfectly when running reports, and now I'm running them in two different applications here. I can send you a copy.
    Warren Ayen
    Senior C# Developer
    DLS Software Studios (http://www.dlssoftwarestudios.com/)

    I use Microsoft Visual Studio 2005, 2008, working with Visual Basic and Visual C#
    Hey! If you like my post, or I solve your issue, please Rate Me!

  7. #7

    Thread Starter
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: [2005] BO XI R2 db connection issue

    I would appreciate any help. This is driving me nuts. I got the code to work for 2 different database (see below). But, this "randomness" is getting to me. It seems like every new version of Crystal reports entails relearning everything (with precious little documentation). I even installed the latest MHF & CHF. That didn't change anything.

    VB Code:
    1. Friend Class CRViewer
    2.     Inherits System.Windows.Forms.Form
    3.     'Private rsMachine As ADODB.Recordset
    4.     'Private Const PARAMETER_FIELD_NAME As String = "Machine"
    5.  
    6.     Private Sub ConfigureCrystalReports()
    7.  
    8.         CRViewer1.ReportSource = Nothing
    9.         CRViewer1.SelectionFormula = ""
    10.  
    11.         Dim myConnectionInfo As ConnectionInfo
    12.         Dim myConnectionInfo2 As ConnectionInfo
    13.         Dim ReportPath As String
    14.         'Dim myArrayList As ArrayList = New ArrayList()
    15.         'Dim myParameterFields As ParameterFields
    16.         Dim mySelectionFormula As String = ""
    17.         myConnectionInfo = New ConnectionInfo
    18.         With myConnectionInfo
    19.             .ServerName = "Primero"
    20.             .DatabaseName = "Tooling"
    21.             .UserID = "sa"
    22.             .Password = myPasswordTechniSQL
    23.         End With
    24.         myConnectionInfo2 = New ConnectionInfo
    25.         With myConnectionInfo2
    26.             .ServerName = "Primero"
    27.             .DatabaseName = "Techni"
    28.             .UserID = "sa"
    29.             .Password = myPasswordTechniSQL
    30.         End With
    31.  
    32.  
    33.         Select Case glbReportname
    34.             Case "Z:\Tooling\PartialToolList.rpt"
    35.                 'myArrayList.Add(glbreportParam)
    36.                 'myParameterFields = CRViewer1.ParameterFieldInfo
    37.                 'SetCurrentValuesForParameterField(myParameterFields, myArrayList)
    38.                 mySelectionFormula = "{MachineTool.Machine} = " & Val(glbreportParam)
    39.                 ReportPath = Application.StartupPath & "\PartialToolList.rpt"
    40.                 CRViewer1.SelectionFormula = mySelectionFormula
    41.                 CRViewer1.ReportSource = ReportPath
    42.                 SetDBLogonForReport(myConnectionInfo, myConnectionInfo2)
    43.             Case "Z:\Tooling\Tooling.rpt"
    44.                 ReportPath = Application.StartupPath & "\Tooling.rpt"
    45.                 CRViewer1.ReportSource = ReportPath
    46.                 SetDBLogonForReport(myConnectionInfo, myConnectionInfo2)
    47.             Case "Z:\Tooling\FullToolList.rpt"
    48.                 ReportPath = Application.StartupPath & "\FullToolList.rpt"
    49.                 CRViewer1.ReportSource = ReportPath
    50.                 SetDBLogonForReport(myConnectionInfo, myConnectionInfo2)
    51.             Case "Z:\Tooling\Xref.rpt"
    52.                 ReportPath = Application.StartupPath & "\Xref.rpt"
    53.                 CRViewer1.ReportSource = ReportPath
    54.                 SetDBLogonForReport(myConnectionInfo, myConnectionInfo2)
    55.         End Select
    56.  
    57.         'CRViewer1.Show()
    58.     End Sub
    59.    
    60.     Private Sub SetDBLogonForReport(ByVal myConnecionInfo As ConnectionInfo, ByVal myConnecionInfo2 As ConnectionInfo)
    61.         Dim myTableLogOnInfos As TableLogOnInfos = CRViewer1.LogOnInfo
    62.  
    63.         For Each myTableLogOnInfo As TableLogOnInfo In myTableLogOnInfos
    64.             If myTableLogOnInfo.TableName = "Unprinted" Then
    65.                 myTableLogOnInfo.ConnectionInfo = myConnecionInfo2
    66.             Else
    67.                 myTableLogOnInfo.ConnectionInfo = myConnecionInfo
    68.             End If
    69.         Next
    70.  
    71.     End Sub

  8. #8

    Thread Starter
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: [2005] BO XI R2 db connection issue

    OK. I went stepping through the code. The errors are occurring in thsi code:

    [vbocde]
    Private Sub SetDBLogonForReport(ByVal myConnecionInfo As ConnectionInfo, ByVal myConnecionInfo2 As ConnectionInfo)
    Dim myTableLogOnInfos As TableLogOnInfos = CRViewer1.LogOnInfo

    For Each myTableLogOnInfo As TableLogOnInfo In myTableLogOnInfos
    If UCase(myTableLogOnInfo.TableName) = "UNPRINTED" Then
    myTableLogOnInfo.ConnectionInfo = myConnecionInfo2
    Else
    myTableLogOnInfo.ConnectionInfo = myConnecionInfo
    End If
    Next

    End Sub
    [/Highlight]

    It hits this line:
    Dim myTableLogOnInfos As TableLogOnInfos = CRViewer1.LogOnInfo

    and I get the "Load report failed" error, and it has me supply the password (it seems to maintain the usercode). I do this for both databases, the report displys, I get the Load error again. i close the report and it steps to the next line (the FOR loop). Every tablename in the loop is blank.

    So, maybe if I can resolve the "DIM" issue, the other stuff will fall into place.

  9. #9
    Fanatic Member
    Join Date
    Aug 2006
    Location
    Chicago, IL
    Posts
    514

    Re: [2005] BO XI R2 db connection issue

    VB Code:
    1. Private Sub ConfigureCrystalReports()
    2.  
    3.         Dim myConnectionInfo As ConnectionInfo
    4.         Dim ReportPath As String
    5.  
    6.  
    7.  
    8.         myConnectionInfo = New ConnectionInfo
    9.  
    10.         With myConnectionInfo
    11.             .ServerName = "Gemini"
    12.             .DatabaseName = "New_Inv_Dev"
    13.             .UserID = "sa"
    14.             .Password = "bobcre10"
    15.         End With
    16.  
    17.         ReportPath = reportFilename
    18.  
    19.         CRViewer1.ReportSource = ReportPath
    20.  
    21.         SetDBLogonForReport(myConnectionInfo)
    22.  
    23.  
    24.         CRViewer1.Show()
    25.     End Sub
    26.  
    27.     Private Sub CRViewer_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
    28.         Try
    29.  
    30.             ConfigureCrystalReports()
    31.  
    32.         Catch ex As Exception
    33.  
    34.             Kinsale.DisplayMessage("Crystal Reports was unable to load the report: " & ex.Message, "", KinsaleClass.retExclamation, False, False)
    35.  
    36.         End Try
    37.  
    38.  
    39.     End Sub
    40.  
    41.     Private Sub SetDBLogonForReport(ByVal myConnecionInfo As ConnectionInfo)
    42.         Dim myTableLogOnInfos As TableLogOnInfos = CRViewer1.LogOnInfo
    43.  
    44.         For Each myTableLogOnInfo As TableLogOnInfo In myTableLogOnInfos
    45.             myTableLogOnInfo.ConnectionInfo = myConnecionInfo
    46.         Next
    47.  
    48.     End Sub

    That's my code. Works perfectly. It only uses one database, though.
    Warren Ayen
    Senior C# Developer
    DLS Software Studios (http://www.dlssoftwarestudios.com/)

    I use Microsoft Visual Studio 2005, 2008, working with Visual Basic and Visual C#
    Hey! If you like my post, or I solve your issue, please Rate Me!

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