|
-
Nov 20th, 2006, 09:05 AM
#1
Thread Starter
PowerPoster
** 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:
Case "Z:\Tooling\Xref.rpt"
ReportPath = Application.StartupPath & "\Xref.rpt"
CRViewer1.ReportSource = ReportPath
Dim myTableLogOnInfos As TableLogOnInfos = CRViewer1.LogOnInfo
For Each myTableLogOnInfo As TableLogOnInfo In myTableLogOnInfos
If report.name = "Unprinted" Then
myTableLogOnInfo.ConnectionInfo = myConnecionInfo2
Else
myTableLogOnInfo.ConnectionInfo = myConnecionInfo
End If
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:
Dim myConnectionInfo As ConnectionInfo
Dim myConnectionInfo2 As ConnectionInfo
Dim ReportPath As String
Dim mySelectionFormula As String = ""
myConnectionInfo = New ConnectionInfo
With myConnectionInfo
.ServerName = "Primero"
.DatabaseName = "Tooling"
.UserID = "sa"
.Password = myPasswordTechniSQL
End With
With myConnectionInfo2
.ServerName = "Primero"
.DatabaseName = "Techni"
.UserID = "sa"
.Password = myPasswordTechniSQL
End With
Last edited by Pasvorto; Nov 21st, 2006 at 10:55 AM.
-
Nov 20th, 2006, 09:49 AM
#2
Fanatic Member
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!
-
Nov 20th, 2006, 10:09 AM
#3
Thread Starter
PowerPoster
Re: [2005] BO XI R2 db connection issue
I guess I don't understand what you mean.
-
Nov 20th, 2006, 10:11 AM
#4
Fanatic Member
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:
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!
-
Nov 20th, 2006, 10:30 AM
#5
Thread Starter
PowerPoster
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?
-
Nov 20th, 2006, 10:31 AM
#6
Fanatic Member
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!
-
Nov 20th, 2006, 10:43 AM
#7
Thread Starter
PowerPoster
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:
Friend Class CRViewer
Inherits System.Windows.Forms.Form
'Private rsMachine As ADODB.Recordset
'Private Const PARAMETER_FIELD_NAME As String = "Machine"
Private Sub ConfigureCrystalReports()
CRViewer1.ReportSource = Nothing
CRViewer1.SelectionFormula = ""
Dim myConnectionInfo As ConnectionInfo
Dim myConnectionInfo2 As ConnectionInfo
Dim ReportPath As String
'Dim myArrayList As ArrayList = New ArrayList()
'Dim myParameterFields As ParameterFields
Dim mySelectionFormula As String = ""
myConnectionInfo = New ConnectionInfo
With myConnectionInfo
.ServerName = "Primero"
.DatabaseName = "Tooling"
.UserID = "sa"
.Password = myPasswordTechniSQL
End With
myConnectionInfo2 = New ConnectionInfo
With myConnectionInfo2
.ServerName = "Primero"
.DatabaseName = "Techni"
.UserID = "sa"
.Password = myPasswordTechniSQL
End With
Select Case glbReportname
Case "Z:\Tooling\PartialToolList.rpt"
'myArrayList.Add(glbreportParam)
'myParameterFields = CRViewer1.ParameterFieldInfo
'SetCurrentValuesForParameterField(myParameterFields, myArrayList)
mySelectionFormula = "{MachineTool.Machine} = " & Val(glbreportParam)
ReportPath = Application.StartupPath & "\PartialToolList.rpt"
CRViewer1.SelectionFormula = mySelectionFormula
CRViewer1.ReportSource = ReportPath
SetDBLogonForReport(myConnectionInfo, myConnectionInfo2)
Case "Z:\Tooling\Tooling.rpt"
ReportPath = Application.StartupPath & "\Tooling.rpt"
CRViewer1.ReportSource = ReportPath
SetDBLogonForReport(myConnectionInfo, myConnectionInfo2)
Case "Z:\Tooling\FullToolList.rpt"
ReportPath = Application.StartupPath & "\FullToolList.rpt"
CRViewer1.ReportSource = ReportPath
SetDBLogonForReport(myConnectionInfo, myConnectionInfo2)
Case "Z:\Tooling\Xref.rpt"
ReportPath = Application.StartupPath & "\Xref.rpt"
CRViewer1.ReportSource = ReportPath
SetDBLogonForReport(myConnectionInfo, myConnectionInfo2)
End Select
'CRViewer1.Show()
End Sub
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 myTableLogOnInfo.TableName = "Unprinted" Then
myTableLogOnInfo.ConnectionInfo = myConnecionInfo2
Else
myTableLogOnInfo.ConnectionInfo = myConnecionInfo
End If
Next
End Sub
-
Nov 20th, 2006, 11:35 AM
#8
Thread Starter
PowerPoster
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.
-
Nov 21st, 2006, 10:45 AM
#9
Fanatic Member
Re: [2005] BO XI R2 db connection issue
VB Code:
Private Sub ConfigureCrystalReports()
Dim myConnectionInfo As ConnectionInfo
Dim ReportPath As String
myConnectionInfo = New ConnectionInfo
With myConnectionInfo
.ServerName = "Gemini"
.DatabaseName = "New_Inv_Dev"
.UserID = "sa"
.Password = "bobcre10"
End With
ReportPath = reportFilename
CRViewer1.ReportSource = ReportPath
SetDBLogonForReport(myConnectionInfo)
CRViewer1.Show()
End Sub
Private Sub CRViewer_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
Try
ConfigureCrystalReports()
Catch ex As Exception
Kinsale.DisplayMessage("Crystal Reports was unable to load the report: " & ex.Message, "", KinsaleClass.retExclamation, False, False)
End Try
End Sub
Private Sub SetDBLogonForReport(ByVal myConnecionInfo As ConnectionInfo)
Dim myTableLogOnInfos As TableLogOnInfos = CRViewer1.LogOnInfo
For Each myTableLogOnInfo As TableLogOnInfo In myTableLogOnInfos
myTableLogOnInfo.ConnectionInfo = myConnecionInfo
Next
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|