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

Hints For Dynamic Database...

Status
Not open for further replies.

Hattusas

Programmer
Nov 11, 2001
344
TR
This tip consists of information obtained from seagate web site and additionally my researches.I have had problems with SCR about connecting different databases but could not find satistified solution.Now I have solved tihs problem and here are the complete steps...

First you shouldn't forget that
1.You can not connect to database dynamically if you are using Crystal Web Reports Server.ASP (Active Server Pages) allows you to connect dynamically.

Below is an example of ASP syntax.
a.)URL
Here is my sample url.Assume that my report name is report1,
the server name is GJTIST04 and database name is OGERTUR.This report will have 5 parameters.2 number,2 date and finally 2 string parameters.
address of my asp file)?Server=GJTIST04?Database=OGERTUR?Param1=100?Param2=1000?
Param3=01/01/2001?Param4=31/12/2001?Param5=A?Param6=Z

b.)ASP Syntax

<%@ LANGUAGE=&quot;VBSCRIPT&quot; %>
<title>Report Title Goes Here </title>
<%
reportname = &quot;RezervasyonOtelMun.rpt&quot;
%>
<%
If Not IsObject (session(&quot;oApp&quot;)) Then
Set session(&quot;oApp&quot;) = Server.CreateObject(&quot;Crystal.CRPE.Application&quot;)
End If

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

Session.Timeout=10
If IsObject(session(&quot;oRpt&quot;)) then
Set session(&quot;oRpt&quot;) = nothing
End if



Set session(&quot;oRpt&quot;) = session(&quot;oApp&quot;).OpenReport(Path & reportName , 1)


'Database User And Password
userid = &quot;db2admin&quot;
password = &quot;db2admin&quot;
'Those were my user name and password

' Set the location
set crtable = session(&quot;oRpt&quot;).Database.Tables.Item(1)
crtable.SetLogonInfo Request.QueryString(&quot;Server&quot;), Request.QueryString(&quot;Database&quot;), cstr(userid), cstr(password)

' Parameters

session(&quot;oRpt&quot;).DiscardSavedData


set session(&quot;ParamCollection&quot;) = Session(&quot;oRpt&quot;).Parameterfields


set Param1 = session(&quot;ParamCollection&quot;).Item(1)
ParamValue1 = Request.QueryString(&quot;Param1&quot;)
Call Param1.SetCurrentValue (ParamValue1)

set Param2 = session(&quot;ParamCollection&quot;).Item(2)
ParamValue2 = Request.QueryString(&quot;Param2&quot;)
Call Param2.SetCurrentValue (ParamValue2)

set Param3 = session(&quot;ParamCollection&quot;).Item(3)
ParamValue3 = Request.QueryString(&quot;Param3&quot;)
Call Param3.SetCurrentValue (DateValue(ParamValue3))

set Param4 = session(&quot;ParamCollection&quot;).Item(4)
ParamValue4 = Request.QueryString(&quot;Param4&quot;)
Call Param4.SetCurrentValue (DateValue(ParamValue4))

set Param5 = session(&quot;ParamCollection&quot;).Item(5)
ParamValue5 = Request.QueryString(&quot;Param5&quot;)
Call Param5.SetCurrentValue (Cstr(ParamValue5))

set Param6 = session(&quot;ParamCollection&quot;).Item(6)
ParamValue6 = Request.QueryString(&quot;Param6&quot;)
Call Param6.SetCurrentValue (Cstr(ParamValue6))

%>
<%

On Error Resume Next
session(&quot;oRpt&quot;).ReadRecords
If Err.Number <> 0 Then
Response.Write &quot;An Error has occured on the server in attempting to access the data source&quot;
Else

If IsObject(session(&quot;oPageEngine&quot;)) Then
set session(&quot;oPageEngine&quot;) = nothing
End If
set session(&quot;oPageEngine&quot;) = session(&quot;oRpt&quot;).PageEngine
End If
%>
'ActiveX Driver
<!-- #include file=&quot;SmartViewerActiveX.asp&quot; -->

c.) SmartViewerActiveX.asp syntax...
<%
%>
<HTML>
<HEAD>
<TITLE>Seagate ActiveX Viewer</TITLE>
</HEAD>
<BODY BGCOLOR=C6C6C6 LANGUAGE=VBScript ONLOAD=&quot;Page_Initialize&quot;>

<OBJECT ID=&quot;CRViewer&quot;
CLASSID=&quot;CLSID:C4847596-972C-11D0-9567-00A0C9273C2A&quot;
WIDTH=100% HEIGHT=95%
CODEBASE=&quot;/viewer/activeXViewer/activexviewer.cab#Version=8,0,0,224&quot;>
<PARAM NAME=&quot;EnableRefreshButton&quot; VALUE=0>
<PARAM NAME=&quot;EnableGroupTree&quot; VALUE=1>
<PARAM NAME=&quot;DisplayGroupTree&quot; VALUE=1>
<PARAM NAME=&quot;EnablePrintButton&quot; VALUE=1>
<PARAM NAME=&quot;EnableExportButton&quot; VALUE=1>
<PARAM NAME=&quot;EnableDrillDown&quot; VALUE=1>
<PARAM NAME=&quot;EnableSearchControl&quot; VALUE=1>
<PARAM NAME=&quot;EnableAnimationControl&quot; VALUE=1>
<PARAM NAME=&quot;EnableZoomControl&quot; VALUE=1>
</OBJECT>

<SCRIPT LANGUAGE=&quot;VBScript&quot;>
<!--
Sub Page_Initialize
On Error Resume Next
Dim webBroker
Set webBroker = CreateObject(&quot;WebReportBroker.WebReportBroker&quot;)
if ScriptEngineMajorVersion < 2 then
window.alert &quot;IE 3.02 users on NT4 need to get the latest version of VBScript or install IE 4.01 SP1. IE 3.02 users on Win95 need DCOM95 and latest version of VBScript, or install IE 4.01 SP1. These files are available at Microsoft's web site.&quot;
CRViewer.ReportName = &quot;rptserver.asp&quot;
else
Dim webSource
Set webSource = CreateObject(&quot;WebReportSource.WebReportSource&quot;)
webSource.ReportSource = webBroker
webSource.URL = &quot;rptserver.asp&quot;
webSource.PromptOnRefresh = True
CRViewer.ReportSource = webSource
end if
CRViewer.ViewReport
End Sub
-->
</SCRIPT>
</BODY>
</HTML>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top