Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help!! Crystal Report 9 dynamic fields with asp!!!???

Status
Not open for further replies.

chrisserB

Programmer
Sep 9, 2002
2
DK
Hi Everyone!

I have a problem with Report Application Server SDK! (RAS)
What I am trying to do is to dynamically create a report..
I would like define what fields i would like on the report
from a asp page... So i have worked out an example, which
works to some extend:

--- ASP code ---

<!--#include file=&quot;../include/database.inc&quot;-->
<%db = Session(&quot;db&quot;)
openDB db

'*** Constants ***
Dim adUseClient
Dim adOpenDynamic

adUseClient = 3
adOpenDynamic = 2
'*** End Constants ***

'*** Declarations ***
Dim oConnection 'as ADODB.Connection
Dim oRecordSet 'as ADODB.Recordset
Dim Field 'as ADODB.Field
Dim ObjectFactory 'as CrystalReports.ObjectFactory.2
'Dim session(&quot;oClientDoc&quot;) 'as CrystalClientDoc.ReportClientDocument
Dim HTMLViewer 'as CrystalReports.CrystalReportInteractiveViewer
Dim Reportname 'as String
Dim Path 'as String
Dim iLen 'as Integer
Dim viewer
'*** End Declarations ***

Set oConnection = CreateObject(&quot;ADODB.Connection&quot;)
Set oRecordSet = CreateObject(&quot;ADODB.Recordset&quot;)
oConnection.Open conn
oRecordSet.CursorType = adOpenDynamic
oRecordSet.CursorLocation = adUseClient
oRecordSet.Open session(&quot;sql&quot;), oConnection

Reportname = &quot;bilagsliste.rpt&quot;
Path = Request.ServerVariables(&quot;Path_Translated&quot;)
While (Right(Path, 1) <> &quot;\&quot; And Len(Path) <> 0)
iLen = Len(Path) - 1
Path = Left(Path, iLen)
Wend


'Create the ObjectFactory to instantiate Crystal Objects
Set ObjectFactory = CreateObject(&quot;CrystalReports.ObjectFactory.2&quot;)
'Create the ReportClientDocument
Set session(&quot;oClientDoc&quot;) = ObjectFactory.CreateObject(&quot;CrystalClientDoc.ReportClientDocument&quot;)

'Open the report.
session(&quot;oClientDoc&quot;).Open (path & reportname)
'Set the Datasource of the report to the Recordset.
session(&quot;oClientDoc&quot;).DatabaseController.SetDataSource oRecordSet, session(&quot;oClientDoc&quot;).Database.Tables.Item(0).Name, &quot;ADORecordSet&quot;

Dim sql_profil,Pos, strHeader
Dim strField, strTable, FieldIndex, Table
sql_profil = &quot;SELECT * FROM Profil_detalje WHERE type = 1 AND profil_id = &quot;&Request.QueryString(&quot;profil_id&quot;)&&quot; ORDER BY raekkefoelge&quot;
Set rsProfil = Server.CreateObject(&quot;ADODB.Recordset&quot;)
rsProfil.Open sql_profil, conn

With session(&quot;oClientDoc&quot;).DatabaseController
.ModifyFieldHeading session(&quot;oClientDoc&quot;).Database.Tables(0).DataFields(0), &quot;2222&quot;
End With
IF not rsProfil.EOF then
DO WHILE NOT rsProfil.EOF
strTable = rsProfil(&quot;tabel_navn&quot;)
strField = rsProfil(&quot;felt_navn&quot;)
strHeader = rsProfil(&quot;overskrift&quot;)

With session(&quot;oClientDoc&quot;).DatabaseController.Database
Set Table = .Tables.Item(.Tables.FindByAlias(strTable))
FieldIndex = Table.DataFields.Find(strField,0)
Set FieldToAdd = Table.DataFields.Item(FieldIndex)
End With
'.ModifyFieldHeading FieldToAdd, strHeader


With session(&quot;oClientDoc&quot;).DataDefController.ResultFieldController .Add -1, FieldToAdd
End With


rsProfil.movenext
LOOP
END IF

-----


problems!

The size of every added field to the report are fixed???!
they have the same width, which is not what i want!!
How do i set the width for a field?????
is it possible???

I am also trying to add headers with modifyfieldheading..
which does not seem to work? why not?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top