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

Dynamic database connection problem

Status
Not open for further replies.

Swnymor

IS-IT--Management
Feb 15, 2005
1
GB
Hi,

Wondering if anyone can help me, I have a suite of reports in version 9 running using RAS via an asp script. This works fine but I now need to change the database name from inside the asp script before calling the .rpt through the viewer.

Can anyone help???? I've included the asp script I am using below..

Stu

<%
Option Explicit
Response.ContentType = "text/html; charset=utf-8"

Dim objectFactory
Set objectFactory = CreateObject("CrystalReports.ObjectFactory.2")

Response.ExpiresAbsolute = Now() - 1

Dim viewer
Set viewer = objectFactory.CreateObject("CrystalReports.CrystalReportInteractiveViewer")
viewer.Name = "page"
viewer.IsOwnForm = true
viewer.IsOwnPage = true
viewer.EnableParameterPrompt = false
viewer.IsDisplayGroupTree = false
viewer.HasHeaderArea = False
viewer.hasexportbutton = True
viewer.isenabledrilldown = True

Dim theReportName
theReportName = Request.Form("ReportName")
if theReportName = "" then theReportName = Request.QueryString("ReportName")
viewer.URI = "STU001.asp?ReportName=" + Server.URLEncode(theReportName) + "&language=" + Request.QueryString("language") + "&Keyword=" + Request.QueryString("Keyword")


Dim clientDoc
Set clientDoc = objectFactory.CreateObject("CrystalClientDoc.ReportClientDocument")
clientDoc.Open theReportName

viewer.ReportSource = clientDoc.ReportSource

Dim NewParam0
Set NewParam0 = ObjectFactory.CreateObject("CrystalReports.ParameterField")
With clientDoc.DataDefinition.ParameterFields .Item(0).CopyTo NewParam0
Dim NewVal0
Dim ValContent0
ValContent0 = Request.Form("language")
if ValContent0 = "" then ValContent0 = Request.QueryString("language")
Set NewVal0 = ObjectFactory.CreateObject("CrystalReports.ParameterFieldDiscreteValue")
NewVal0.Value = ValContent0
NewParam0.CurrentValues.add NewVal0
clientDoc.DataDefController.ParameterFieldController.Modify .Item(0), NewParam0
End With

Dim NewParam1
Set NewParam1 = ObjectFactory.CreateObject("CrystalReports.ParameterField")
With clientDoc.DataDefinition.ParameterFields .Item(1).CopyTo NewParam1
Dim NewVal1
Dim ValContent1
ValContent1 = Request.Form("Keyword")
if ValContent1 = "" then ValContent1 = Request.QueryString("Keyword")
Set NewVal1 = ObjectFactory.CreateObject("CrystalReports.ParameterFieldDiscreteValue")
NewVal1.Value = ValContent1
NewParam1.CurrentValues.add NewVal1
clientDoc.DataDefController.ParameterFieldController.Modify .Item(1), NewParam1
End With

Dim BooleanSearchControl
Set BooleanSearchControl = objectFactory.CreateObject("CrystalReports.BooleanSearchControl")
BooleanSearchControl.ReportDocument = clientDoc
viewer.BooleanSearchControl = BooleanSearchControl
viewer.ProcessHttpRequest Request, Response, Session
' ReportClientDocument will be automatically closed when clientDoc is released
%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top