Hi Henry,
Don't give up on crystal; it's a great if not perfect report writer.
I've written apps that call on hundreds of crystal reports and they too had
to have connection info appropriate for my test server and different
connection info for the client's server. There are numerous articles on
this issue at crystal, but I will list below a sub I use to convert the
connection before a report runs. First, remember to make all of your
reports integrated security false (datasource location in the report menu),
so that the connection you are using is not hard coded into it.
Then, when you run the report, run them first against a routine such as that
below; my variables globalservernam e, globalusername, etc are set when the
app begins by accessing a simple text file that contains this info (like an
ini file) and assigning the appropriate global string with the necessary
info.
HTH - let me know if you have any questions.
Bernie Yaeger
PS - here's the code:
Public Sub connectionchang e()
'Dim crreportdocumen t As New ReportDocument
Dim crtablelogoninf os As New TableLogOnInfos
Dim crtablelogoninf o As New TableLogOnInfo
Dim crconnectioninf o As New ConnectionInfo
Dim crtables As Tables
Dim crtable As Table
Dim tablecounter As Integer
crreportdocumen t.Load(gl_brows eprintvar,
OpenReportMetho d.OpenReportByT empCopy)
With crconnectioninf o
..DatabaseName = "IMC"
..ServerName = globalservernam e
..UserID = globalusername
..Password = globalpwd
End With
crtablelogoninf o.ConnectionInf o = crconnectioninf o
crtables = crreportdocumen t.Database.Tabl es
For Each crtable In crtables
If (Mid(crtable.Na me, 1, 4) = "magt" Or Mid(crtable.Nam e, 1, 4) = "magb" Or
Mid(crtable.Nam e, 1, 4) = "magf") And gl_browseprintv ar =
"f:\imcapps\hvs um.rpt" Then
crconnectioninf o.DatabaseName = "imc_extra"
crtablelogoninf o.ConnectionInf o = crconnectioninf o
Else
crconnectioninf o.DatabaseName = "IMC"
crtablelogoninf o.ConnectionInf o = crconnectioninf o
End If
crtable.ApplyLo gOnInfo(crtable logoninfo)
crtable.Locatio n = crtable.Name
Next
Dim subRepDoc As New ReportDocument
Dim crSection As Section
Dim crReportObject As ReportObject
Dim crSubreportObje ct As SubreportObject
For Each crSection In crreportdocumen t.ReportDefinit ion.Sections
For Each crReportObject In crSection.Repor tObjects
If crReportObject. Kind = ReportObjectKin d.SubreportObje ct Then
crSubreportObje ct = CType(crReportO bject, SubreportObject )
subRepDoc = crSubreportObje ct.OpenSubrepor t(crSubreportOb ject.SubreportN ame)
For Each crtable In subRepDoc.Datab ase.Tables
crtable.ApplyLo gOnInfo(crtable logoninfo)
crtable.Locatio n = crtable.Name
Next
End If
Next
Next
CrystalReportVi ewer1.ReportSou rce = crreportdocumen t
End Sub
"Henry" <an*******@devd ex.com> wrote in message
news:ud******** ******@tk2msftn gp13.phx.gbl...
I am writing a Windows forms VB.Net/MS SQL application that utilizes
Crystal Reports. I want to be able to dynamically set the report data
source at run time. According to article
"cr_rdc9_connec tionproperties. pdf" on the Crystal support web site I
should be able to do the following:
Dim ConnectionInfo As CRAXDRT.Connect ionProperties
I get a "Type CRAXDRT.connect ionProperties is not defined" error from
the VS designer when I enter the statement.
I have put in the dll reference in the project to CRAXDRT.
Statements such as the following do work:
Dim objApp As New CRAXDRT.Applica tion
Dim objReport As CRAXDRT.Report
"ConnectionProp erties" does not show up as an item for selection in the
dropdown- Application, Report, etc. do
Any help/guidance much appreciated.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!