Dear All,
I'm new to Crystal Reprots and ASP, and need advises regarding to my problem below
I have two database in same SQL 2005 SERVER for TEST and LIVE Environtment, and I've created more than 100 reports with Crystal Reports 11 and call it from ASP classic page.
The problem is how can I change a database from TEST01 to LIVE01 at the run time from ASP code (including the sub reports) as I already using TEST01 database with ADO Connection on Crystal Reports and I do not want to set a new database location inside crystal for each reports
Thanks and wait for your reply soon.
Below is my code, which has no effect to crystal reports although I've change the database from TEST01 to LIVE01:
<%
Dim oADOConnection, oRptTable, oADORecordset, sql
Dim struser, strpwd, strdriver, dblocation, dbname, strConnect
struser = "sa"
strpwd = "sa"
strdriver = "{SQL SERVER}"
dblocation = "SQL200501"
dbname = "LIVE01" ' Changed from TEST01 to LIVE01
strConnect = "User Id=" & strUser & ";"
strConnect = strConnect & "PWD=" & strPwd & ";"
strConnect = strConnect & "DRIVER=" & StrDriver & ";"
strConnect = strConnect & "SERVER=" & DBLocation & ";"
strConnect = strConnect & "DATABASE=" & dbName
sql="Select * from Employee"
Set session("oApp") = Server.CreateObject("CrystalRuntime.Application.11")
Set session("oRpt") = session("oApp").OpenReport("C:\REPORTS\RPT01.RPT", 1) 'USING TEST01 DATABASE
session("oRpt").MorePrintEngineErrorMessages = False
session("oRpt").EnableParameterPrompting = False
session("oRpt").DiscardSavedData
Set oADOConnection = Server.CreateObject("ADODB.Connection")
oADOConnection.Open (strConnect)
Set oADORecordset = Server.CreateObject("ADODB.Recordset")
Set oRptTable = session("oRpt").Database.Tables.Item(1)
oRptTable.SetDataSource oADORecordset, 3
session("oRpt").SQLQueryString = CStr(sql)
session("oRpt").ReadRecords
%>See if you find answer here
http://support.businessobjects.com
Wednesday, March 21, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment