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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crystal report 9 RAS (ASP): connection-less connection!

Status
Not open for further replies.

wolfieman

Programmer
Oct 17, 2002
10
0
0
DK
Hi everyone!

We are programming in ASP and using the report application server SDK.
But we have ran into a problem. Our solution works fine locally, but when
we moved it to the customer we got the problem. The problem is that
our report is attached to a certain DSN.

What we want to achieve is a connection-less connection. Therefore we are
using the report application server SDK through ASP to achieve that we at
runtime can tell the report which DSN and other database information that
it should use.

in the code below, we have shown our effort. What we have tried is this:

We have tried to grab all the tables into a "table collection", and
for each table available in the report change the database connection.

To see the changes we call the "GetDatabaseInformation" function,
which shows the changes. It looks like there has been made a change,
because when we call the "GetDatabaseInformation" function, it will
show us that the correct database DSN. But the report is NOT connectionless,
because the changes are not affective!...Is this a Bug?

The report will be show no mather what information we put in.. For example:
ODBC_ConnectionProperties.Item("Database Name") = "
No database connection......

How should the approach else be? we have tried many approaches with no success...

sincerly
jan tovgaard





<%
Session.Codepage = 1252
%>
<!-- #include file=&quot;../include/database.inc&quot;-->
<%

Function GetDatabaseInformation(Report)
Response.Write &quot;<br>Fetching database information.... <BR>&quot;
With Report.DatabaseController
If .CanExecuteSQL Then
Response.Write &quot;All connections are SQL executable and from same data source.<BR>&quot;
Else
Response.Write &quot;Not all connections are SQL executable, nor are they from same data source.<BR>&quot;
End If

Dim CIs
Set CIs = Report.DatabaseController.GetConnectionInfos(Nothing)
For Each CI In CIs
Response.Write &quot;Kind: &quot; & CStr(CI.Kind) & &quot;<BR>&quot;
Response.Write &quot;UserName: &quot; & CI.UserName & &quot;<BR>&quot;
Response.Write &quot;Password: &quot; & CI.Password & &quot;<BR>&quot;
Response.Write &quot;Connection information:<BR>&quot;
'CI.Attributes.Item(&quot;QE_ServerDescription&quot;) = &quot;11EGBolig&quot;
For Each Id In CI.Attributes.PropertyIDs
If Not IsObject(CI.Attributes.Item(Id)) Then
Response.Write &quot;&nbsp;&nbsp;&nbsp;&quot; & Id & &quot;: &quot; & CI.Attributes.Item(Id) & &quot;<BR>&quot;
Else
'The item is another property bag that you will have to examine.
End If
Next
'Report.DatabaseController.ModifyTableConnectionInfo &quot;kreditor&quot;,CI
Next

'Report.DatabaseController.SetConnectionInfos(CIs)

End With
End Function




Dim db, sql, viewer, iLen, Path, Reportname, sqlK
Dim oConnection 'as ADODB.Connection
Dim oRecordSet 'as ADODB.Recordset
Dim Field 'as ADODB.Field
Dim ObjectFactory 'as CrystalReports.ObjectFactory.2
Dim HTMLViewer 'as CrystalReports.CrystalReportInteractiveViewer
'*** End Declarations ***
db = Session(&quot;egbolig_db&quot;)
openDB db

Set oConnection = CreateObject(&quot;ADODB.Connection&quot;)
Set oRecordSet = CreateObject(&quot;ADODB.Recordset&quot;)
oConnection.Open conn
oRecordSet.CursorType = adOpenDynamic
oRecordSet.CursorLocation = adUseClient
sql = &quot;Select * from rekvstam where Rekvisition=&quot;&FIntSql(Request.QueryString(&quot;rekvnr&quot;))
oRecordSet.Open sql, oConnection

'Set a variable to hold the report name.
Reportname = &quot;../rapporter/rekvisition_DAB.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;egbolig_oClientDoc&quot;) = ObjectFactory.CreateObject(&quot;CrystalClientDoc.ReportClientDocument&quot;)
'Open the report.
session(&quot;egbolig_oClientDoc&quot;).Open (path & reportname)
'Set the Datasource of the report to the Recordset.



'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
For Each Table in session(&quot;egbolig_oClientDoc&quot;).Database.Tables
Set ODBC_ConnectionProperties = Server.CreateObject(&quot;CrystalReports.PropertyBag&quot;)
ODBC_ConnectionProperties.EnsureCapacity (6)
ODBC_ConnectionProperties.Item(&quot;Database DLL&quot;) = &quot;crdb_odbc.dll&quot;'<BR>&quot;Pdsodbc.dll&quot;
'ODBC_ConnectionProperties.Item(&quot;Database Name&quot;) = &quot;C:\Program Files\Crystal Decisions\Crystal Reports '9\Samples\En\Databases\xtreme.mdb&quot;
ODBC_ConnectionProperties.Item(&quot;Database Name&quot;) = &quot; ODBC_ConnectionProperties.Item(&quot;QE_ServerDescription&quot;) = session(&quot;egbolig_db&quot;)
ODBC_ConnectionProperties.Item(&quot;QE_SQLDB&quot;) = true
' ODBC_ConnectionProperties.Item(&quot;QE_DatabaseType&quot;) = &quot;ODBC (RDO)&quot;''
ODBC_ConnectionProperties.Item(&quot;Server Name&quot;) = &quot;GG&quot;& session(&quot;egbolig_db&quot;)
ODBC_ConnectionProperties.Item(&quot;Server Type&quot;) = &quot;ODBC - &quot;& &quot;GG&quot;& session(&quot;egbolig_db&quot;)

Set DatabaseConnection = objectFactory.CreateObject(&quot;CrystalReports.ConnectionInfo&quot;)
DatabaseConnection.Attributes = ODBC_ConnectionProperties
DatabaseConnection.UserName = &quot;sa&quot;
DatabaseConnection.Password = &quot;&quot;
DatabaseConnection.Kind = 5
Table.ConnectionInfo = DatabaseConnection
'session(&quot;egbolig_oClientDoc&quot;).databasecontroller.ModifyTableConnectionInfo Table.alias, DatabaseConnection
Next

GetDatabaseInformation(session(&quot;egbolig_oClientDoc&quot;))

'Set the Datasource of the report to the Recordset.
session(&quot;egbolig_oClientDoc&quot;).DatabaseController.SetDataSource oRecordSet, &quot;rekvstam&quot;, &quot;ADORecordSet&quot;


Response.Redirect(&quot;../CrystalReportPageViewer.asp&quot;)
 
We have a similar problem with reasigning the report to use the database our application is currently using. I believe there are techniques for creating the report with a data definition file or some other meta data definition. I will post here when I find a solution.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top