"cantonarv" <ar******@gmail .com> schrieb im Newsbeitrag
news:11******** **************@ g47g2000cwa.goo glegroups.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).ConnectionIn fo.DatabaseName =
"mySQLDatabaseN ame"
Crystalviewer1. LogOnInfo.Item( 0).ConnectionIn fo.ServerName =
"mySQLServerNAm e"
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(ByVa l blRefreshLocati on As Boolean)
Dim crSections As Sections
Dim crSection As Section
Dim crReportObjects As ReportObjects
Dim crReportObject As ReportObject
Dim crSubreportObje ct As SubreportObject
Dim crReportDocumen t As ReportDocument
Dim crSubreportDocu ment As ReportDocument
Dim crDatabase As Database
Dim crTables As Tables
Dim crTable As Table
Dim crTableLogOnInf o As TableLogOnInfo
Dim crConnectioninf o As ConnectionInfo
Dim myArrayList As ArrayList = New ArrayList
'declare an instance of the report and the connectionInfo object
crReportDocumen t = New ReportDocument
crConnectioninf o = New ConnectionInfo
crReportDocumen t.Load(mstrRepo rtName)
'pass the necessary parameters to the connectionInfo object
With crConnectioninf o
.ServerName = mstrDBServerNam e
.DatabaseName = mstrDataBaseNam e
End With
'set up the database and tables objects to refer to the current
report
crDatabase = crReportDocumen t.Database
crTables = crDatabase.Tabl es
'loop through all the tables and pass in the connection info
For Each crTable In crTables
crTableLogOnInf o = crTable.LogOnIn fo
crTableLogOnInf o.ConnectionInf o = crConnectioninf o
If blRefreshLocati on Then
crTable.Locatio n = mstrDataBaseNam e & ".dbo." &
crTable.Locatio n.Substring(crT able.Location.L astIndexOf(".") + 1)
End If
crTable.ApplyLo gOnInfo(crTable LogOnInfo)
Next
'set the crSections object to the current report's sections
crSections = crReportDocumen t.ReportDefinit ion.Sections
'loop through all the sections to find all the report objects
For Each crSection In crSections
crReportObjects = crSection.Repor tObjects
'loop through all the report objects to find all the subreports
For Each crReportObject In crReportObjects
If crReportObject. Kind = ReportObjectKin d.SubreportObje ct
Then
'you will need to typecast the reportobject to a
subreport
'object once you find it
crSubreportObje ct = CType(crReportO bject,
SubreportObject )
'open the subreport object
crSubreportDocu ment =
crSubreportObje ct.OpenSubrepor t(crSubreportOb ject.SubreportN ame)
'set the database and tables objects to work with the
subreport
crDatabase = crSubreportDocu ment.Database
crTables = crDatabase.Tabl es
'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 crConnectioninf o
.ServerName = mstrDBServerNam e
End With
crTableLogOnInf o = crTable.LogOnIn fo
crTableLogOnInf o.ConnectionInf o = crConnectioninf o
If blRefreshLocati on Then
crTable.Locatio n = mstrDataBaseNam e & ".dbo." &
crTable.Locatio n.Substring(crT able.Location.L astIndexOf(".") + 1)
End If
crTable.ApplyLo gOnInfo(crTable LogOnInfo)
Next
End If
Next
Next
crystalReportVi ewer.ReportSour ce = crReportDocumen t
End Sub
Greeting
Thomas Wenning