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!

Switch data source on run-time for ODBC reporting

Status
Not open for further replies.

ctiuser

Programmer
Dec 5, 2006
1
MY
Hi, I am having problem finding a way to change the data source of my report during run-time. Here are the details:

#General Info#
OS: Windows 2000/XP
Crystal Report: v8.5.0.217
Access: Multi-user web access (ASP + VB Script, using Rptserver.asp v8.5 dated 2001-09-17)
Database Server: MySQL v4.1 (reporting off 1 table only)
Database connection: ODBC

#ODBC settings in Web server#
Data Source Name: app1dsn
Host: localhost
Database Name: app1db
User: root

#Data Source settings in rpt file#
Table: app1db.extensions
Server Type: ODBC - app1dsn
Server Name: app1dsn
Database: app1db
User ID: root

Database "app1db" is the main database, there could be more than 1 historical database (similar structure like main database) like "app1db_hist1", "app1db_hist2", etc. In the web reporting page, I would like to let user choose the database from which they generate report. The database name they choose would then be stored in the variable "sDBname".

Here are the code snippet:

Set session("oApp") = Server.CreateObject("CrystalRuntime.Application")
Set session("oRpt") = session("oApp").OpenReport(sRptPath)
session("oRpt").database.tables(1).SetLogonInfo "app1dsn",sDBName,sUID,sPwd
session("oRpt").SQLQueryString = sSQL
session("oRpt").ReadRecords
...

Now, no matter which database the user selected in the Web reporting page, the report would still be generated using data in "app1db" database since it is the database set in ODBC in Web server. It seems like the sDBname variable that I passed into the application take no effect at all to the data source of the report.

Any idea how can I fix this? Thanks.

J
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top