VB.Net/Crystal Reports - CRAXDRT.ConnectionProperties not defined error

H

Henry

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_connectionproperties.pdf" on the Crystal support web site I
should be able to do the following:

Dim ConnectionInfo As CRAXDRT.ConnectionProperties

I get a "Type CRAXDRT.connectionProperties 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.Application
Dim objReport As CRAXDRT.Report

"ConnectionProperties" does not show up as an item for selection in the
dropdown- Application, Report, etc. do

Any help/guidance much appreciated.
 
S

SStory

good luck. I gave up on Crystal and went to the free Component One reporting
control that is part of .NET Resource Kit.

Shane
 
B

Bernie Yaeger

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 globalservername, 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 connectionchange()



'Dim crreportdocument As New ReportDocument

Dim crtablelogoninfos As New TableLogOnInfos

Dim crtablelogoninfo As New TableLogOnInfo

Dim crconnectioninfo As New ConnectionInfo

Dim crtables As Tables

Dim crtable As Table

Dim tablecounter As Integer

crreportdocument.Load(gl_browseprintvar,
OpenReportMethod.OpenReportByTempCopy)

With crconnectioninfo

..DatabaseName = "IMC"

..ServerName = globalservername

..UserID = globalusername

..Password = globalpwd

End With

crtablelogoninfo.ConnectionInfo = crconnectioninfo

crtables = crreportdocument.Database.Tables

For Each crtable In crtables

If (Mid(crtable.Name, 1, 4) = "magt" Or Mid(crtable.Name, 1, 4) = "magb" Or
Mid(crtable.Name, 1, 4) = "magf") And gl_browseprintvar =
"f:\imcapps\hvsum.rpt" Then

crconnectioninfo.DatabaseName = "imc_extra"

crtablelogoninfo.ConnectionInfo = crconnectioninfo

Else

crconnectioninfo.DatabaseName = "IMC"

crtablelogoninfo.ConnectionInfo = crconnectioninfo

End If

crtable.ApplyLogOnInfo(crtablelogoninfo)

crtable.Location = crtable.Name

Next

Dim subRepDoc As New ReportDocument

Dim crSection As Section

Dim crReportObject As ReportObject

Dim crSubreportObject As SubreportObject

For Each crSection In crreportdocument.ReportDefinition.Sections

For Each crReportObject In crSection.ReportObjects

If crReportObject.Kind = ReportObjectKind.SubreportObject Then

crSubreportObject = CType(crReportObject, SubreportObject)

subRepDoc = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName)

For Each crtable In subRepDoc.Database.Tables

crtable.ApplyLogOnInfo(crtablelogoninfo)

crtable.Location = crtable.Name

Next

End If

Next

Next



CrystalReportViewer1.ReportSource = crreportdocument

End Sub
 
H

Henry

Hi Bernie,

Tks for the quick response and sample code. I will work on it today.

.....Henry
 
H

Henry

Bernie,

I'm trying to change the the reports "integrated security" from TRUE to
FALSE with no success. It is not intuitive ( at least not to me.)

How do I go about doing the change?

....Henry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top