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

RAS changing DB during runtime

Status
Not open for further replies.

pzom

Programmer
Oct 29, 2000
7
US
Hi,

I have a copy of ASP scripts which I modified to accept multiple parameters & database location (ODBC). This enables me to just create one report and run it on different ODBC. This was Crystal Version 8.5.

We purchase new Crystal 9.0 with RAS and my script won't work anymore.

Does anybody have sample ASP scripts that will change the parameters and ODBC connection during run-time?

Thanks,
-Paul
 
This is my first post here, I hope it's OK to dredge up an old post. I also have RAS 9 and I'm trying to use ASP to change the database location (ODBC and Access) to view a report over the web.

The report was created with CR9 on a local PC with Access. Now the report has been moved to a web server with RAS 9 and a different Access database. The only difference between databases is the data stored (table names, columns, etc. are the same).

I've tried Crystal examples, but they're long and unwieldy so I won't post them here. Obviously Crystal's examples aren't working for me anyway. Unfortunately I've only found VB and .Net examples, but I need something in ASP.

Thanks.
 
Update: I've tried the pasted code, but I get an HTTP500 error along the lines of,

RptControllers.dll(0x8004100F)
Logon failed. Details: 01S00:[Microsoft][ODBC Microsoft
Access Driver]Invalid connection string attribute DATABASE
Error in File c:\winnt\temp\{bunch of jargon}.rpt: Unable
to connect: incorrect log on parameters.

For Access, I've set newDSN as the system DSN name, but what should newDBQ be? Help please?


Function ChangeRuntimeDB(ByVal strPath )
'************************************************************************************************
' Use of this code is free; only leave the information below (we all need to eat...)
' AUTHOR: Marco Negri
' CREATED: 18-jul-2003
' COPYRIGHT: Copyright 2003 Marco Negri
' EMAIL: marco@alteasrl.com
' USAGE: Call this function before setting viewer properties; then assign
' htmlViewer.ReportSource = Session("ConInfos").ReportSource
'************************************************************************************************
Dim ReportDoc, objFactory, rptAppSession,ConInfos
Dim reportname, newSqlServerDescription
Dim newUSR, newPWD, newDSN, newDBQ,newConInfos
Dim rasTables, rasTable,oldConnectionInfo,newConnectionAttributes,newConnectionInfo,ConnectionProp,newTable

'Define the dsn and odbc login information to override the connection properties within the report.
newDSN = "myDsnName"
newDBQ = "myDbName"
newUSR = "myUserName"
newPWD = "myPwd"
newSqlServerDescription = "mySqlServerDescription "
'Use the OjectFactory object to abstract the version number
'to one location
Set objFactory = CreateObject("CrystalReports.ObjectFactory.2")
Set rptAppSession = objFactory.CreateObject("CrystalReports.ReportAppSession")
Set ConInfos = objFactory.CreateObject("CrystalReports.ConnectionInfos")
rptAppSession.Initialize
'Create a new ReportClientDocument object for this reportAppSession
Set ReportDoc = rptAppSession.CreateService("CrystalClientDoc.ReportClientDocument")
ReportDoc.Open strPath
Set rasTables = ReportDoc.Database.Tables
' code until here is needed to get the report to modify
For Each rasTable In rasTables
' connectioInfo must be provided for each table
Set newConnectionAttributes = Server.CreateObject("CrystalReports.PropertyBag")
set newTable = Server.CreateObject("CrystalReports.Table")

'£££££ ACCESS
newConnectionAttributes.EnsureCapacity 5
newConnectionAttributes.item("QE_DatabaseType") = "ODBC(RDO)"
newConnectionAttributes.item("Database DLL") = "Crdb_odbc.Dll"
newConnectionAttributes.item("QE_ServerDescription") = newDBQ
newConnectionAttributes.item("QE_SQLDB") = true
Set ConnectionProp = Server.CreateObject("CrystalReports.PropertyBag") '= newDSN
ConnectionProp.EnsureCapacity 2
ConnectionProp.item("DSN") = newDSN
ConnectionProp.item("DATABASE") = "newDbPath"
newConnectionAttributes.item("QE_logonProperties") = ConnectionProp
'£££££££££

Set newConnectionInfo = Server.CreateObject("CrystalReports.ConnectionInfo")
' ALL properties must be properly set; if not, there are errors
newConnectionInfo.Attributes = newConnectionAttributes
newConnectionInfo.UserName = newUSR
newConnectionInfo.Password = newPWD
newConnectionInfo.Kind = 5'oldConnectionInfo.Kind
Set newTable = rasTable.Clone( true)
newTable.ConnectionInfo = newConnectionInfo
' The function underneath simply replace the old qualified name
' (see


I modified the next line, which was breaking before:


newTable.QualifiedName = rasTable.Name
//newTable.QualifiedName = NewTableQualifiedName(rasTable,"newDBName")

ReportDoc.DatabaseController.SetTableLocation rasTable,newTable
Set newConnectionAttributes = nothing
Set newConnectionInfo = nothing
Next
Set Session("ConInfos") = ReportDoc
End Function

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top