470,819 Members | 1,654 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,819 developers. It's quick & easy.

Crystal Reports Viewer - simple dynamic database problem

Just trying to do a basic crystal report and viewing it with dynamic
sql server database but dont no what i'm doing wrong? I am using
integrated security.
Dim myRpt As crpt1 = New crpt1 'Where crpt1 is an existing crystal
report

'set databse interaction with crystal
Crystalviewer1.LogOnInfo.Item(0).ConnectionInfo.Da tabaseName =
"mySQLDatabaseName"
Crystalviewer1.LogOnInfo.Item(0).ConnectionInfo.Se rverName =
"mySQLServerNAme"

Crystalviewer1.ReportSource = myRpt

Nov 21 '05 #1
1 4730

"cantonarv" <ar******@gmail.com> schrieb im Newsbeitrag
news:11**********************@g47g2000cwa.googlegr oups.com...
Just trying to do a basic crystal report and viewing it with dynamic
sql server database but dont no what i'm doing wrong? I am using
integrated security.
Dim myRpt As crpt1 = New crpt1 'Where crpt1 is an existing crystal
report

'set databse interaction with crystal
Crystalviewer1.LogOnInfo.Item(0).ConnectionInfo.Da tabaseName =
"mySQLDatabaseName"
Crystalviewer1.LogOnInfo.Item(0).ConnectionInfo.Se rverName =
"mySQLServerNAme"

Crystalviewer1.ReportSource = myRpt


Hi,

use a dataset like this:
http://support.businessobjects.com/c...etdatasets.pdf
or in a ReportInit like this:
Private Sub ReportInit(ByVal blRefreshLocation As Boolean)

Dim crSections As Sections
Dim crSection As Section
Dim crReportObjects As ReportObjects
Dim crReportObject As ReportObject
Dim crSubreportObject As SubreportObject

Dim crReportDocument As ReportDocument
Dim crSubreportDocument As ReportDocument

Dim crDatabase As Database
Dim crTables As Tables
Dim crTable As Table
Dim crTableLogOnInfo As TableLogOnInfo
Dim crConnectioninfo As ConnectionInfo

Dim myArrayList As ArrayList = New ArrayList

'declare an instance of the report and the connectionInfo object

crReportDocument = New ReportDocument
crConnectioninfo = New ConnectionInfo

crReportDocument.Load(mstrReportName)

'pass the necessary parameters to the connectionInfo object
With crConnectioninfo
.ServerName = mstrDBServerName
.DatabaseName = mstrDataBaseName
End With

'set up the database and tables objects to refer to the current
report
crDatabase = crReportDocument.Database
crTables = crDatabase.Tables

'loop through all the tables and pass in the connection info
For Each crTable In crTables
crTableLogOnInfo = crTable.LogOnInfo
crTableLogOnInfo.ConnectionInfo = crConnectioninfo
If blRefreshLocation Then
crTable.Location = mstrDataBaseName & ".dbo." &
crTable.Location.Substring(crTable.Location.LastIn dexOf(".") + 1)
End If
crTable.ApplyLogOnInfo(crTableLogOnInfo)
Next

'set the crSections object to the current report's sections
crSections = crReportDocument.ReportDefinition.Sections

'loop through all the sections to find all the report objects
For Each crSection In crSections
crReportObjects = crSection.ReportObjects
'loop through all the report objects to find all the subreports
For Each crReportObject In crReportObjects
If crReportObject.Kind = ReportObjectKind.SubreportObject
Then
'you will need to typecast the reportobject to a
subreport
'object once you find it
crSubreportObject = CType(crReportObject,
SubreportObject)

'open the subreport object
crSubreportDocument =
crSubreportObject.OpenSubreport(crSubreportObject. SubreportName)

'set the database and tables objects to work with the
subreport
crDatabase = crSubreportDocument.Database
crTables = crDatabase.Tables

'loop through all the tables in the subreport and
'set up the connection info and apply it to the tables
For Each crTable In crTables
With crConnectioninfo
.ServerName = mstrDBServerName
End With
crTableLogOnInfo = crTable.LogOnInfo
crTableLogOnInfo.ConnectionInfo = crConnectioninfo
If blRefreshLocation Then
crTable.Location = mstrDataBaseName & ".dbo." &
crTable.Location.Substring(crTable.Location.LastIn dexOf(".") + 1)
End If
crTable.ApplyLogOnInfo(crTableLogOnInfo)
Next
End If
Next
Next

crystalReportViewer.ReportSource = crReportDocument

End Sub

Greeting

Thomas Wenning
Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Stephan | last post: by
reply views Thread by Jason | last post: by
17 posts views Thread by Peter Proost | last post: by
3 posts views Thread by Trichy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.