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="../include/database.inc"-->
<%db = Session("db"
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("oClientDoc" '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("ADODB.Connection"
Set oRecordSet = CreateObject("ADODB.Recordset"
oConnection.Open conn
oRecordSet.CursorType = adOpenDynamic
oRecordSet.CursorLocation = adUseClient
oRecordSet.Open session("sql", oConnection
Reportname = "bilagsliste.rpt"
Path = Request.ServerVariables("Path_Translated"
While (Right(Path, 1) <> "\" And Len(Path) <> 0)
iLen = Len(Path) - 1
Path = Left(Path, iLen)
Wend
'Create the ObjectFactory to instantiate Crystal Objects
Set ObjectFactory = CreateObject("CrystalReports.ObjectFactory.2"
'Create the ReportClientDocument
Set session("oClientDoc" = ObjectFactory.CreateObject("CrystalClientDoc.ReportClientDocument"
'Open the report.
session("oClientDoc".Open (path & reportname)
'Set the Datasource of the report to the Recordset.
session("oClientDoc".DatabaseController.SetDataSource oRecordSet, session("oClientDoc".Database.Tables.Item(0).Name, "ADORecordSet"
Dim sql_profil,Pos, strHeader
Dim strField, strTable, FieldIndex, Table
sql_profil = "SELECT * FROM Profil_detalje WHERE type = 1 AND profil_id = "&Request.QueryString("profil_id"&" ORDER BY raekkefoelge"
Set rsProfil = Server.CreateObject("ADODB.Recordset"
rsProfil.Open sql_profil, conn
With session("oClientDoc".DatabaseController
.ModifyFieldHeading session("oClientDoc".Database.Tables(0).DataFields(0), "2222"
End With
IF not rsProfil.EOF then
DO WHILE NOT rsProfil.EOF
strTable = rsProfil("tabel_navn"
strField = rsProfil("felt_navn"
strHeader = rsProfil("overskrift"
With session("oClientDoc".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("oClientDoc".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?
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="../include/database.inc"-->
<%db = Session("db"
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("oClientDoc" '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("ADODB.Connection"
Set oRecordSet = CreateObject("ADODB.Recordset"
oConnection.Open conn
oRecordSet.CursorType = adOpenDynamic
oRecordSet.CursorLocation = adUseClient
oRecordSet.Open session("sql", oConnection
Reportname = "bilagsliste.rpt"
Path = Request.ServerVariables("Path_Translated"
While (Right(Path, 1) <> "\" And Len(Path) <> 0)
iLen = Len(Path) - 1
Path = Left(Path, iLen)
Wend
'Create the ObjectFactory to instantiate Crystal Objects
Set ObjectFactory = CreateObject("CrystalReports.ObjectFactory.2"
'Create the ReportClientDocument
Set session("oClientDoc" = ObjectFactory.CreateObject("CrystalClientDoc.ReportClientDocument"
'Open the report.
session("oClientDoc".Open (path & reportname)
'Set the Datasource of the report to the Recordset.
session("oClientDoc".DatabaseController.SetDataSource oRecordSet, session("oClientDoc".Database.Tables.Item(0).Name, "ADORecordSet"
Dim sql_profil,Pos, strHeader
Dim strField, strTable, FieldIndex, Table
sql_profil = "SELECT * FROM Profil_detalje WHERE type = 1 AND profil_id = "&Request.QueryString("profil_id"&" ORDER BY raekkefoelge"
Set rsProfil = Server.CreateObject("ADODB.Recordset"
rsProfil.Open sql_profil, conn
With session("oClientDoc".DatabaseController
.ModifyFieldHeading session("oClientDoc".Database.Tables(0).DataFields(0), "2222"
End With
IF not rsProfil.EOF then
DO WHILE NOT rsProfil.EOF
strTable = rsProfil("tabel_navn"
strField = rsProfil("felt_navn"
strHeader = rsProfil("overskrift"
With session("oClientDoc".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("oClientDoc".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?