Hi, I've got the following problem:
I've got 8 databases which are all similar, but they've got information from different firms... If I were to put all this data in one database I'd have to reprogram my entire program, which at this moment is not an option.
I'm trying to use 1 report for each database, so when I'm logged on to Firm A I want to see only their data and when logged on to Firm B only theirs.
For the record I'm using Crystal Reports 9 with Visual Basic 6 and an MSSQL-server.
Obviously I've made my report based on the Firm A database.
And the report works fine when I'm logged on to that database, but when I switch databases either I get nothing on my screen or I get the data from the Firm A database...
This is officially driving me insane...
Here is the code I'm using.
Public Appl As New CRAXDRT.Application
Public Report As New CRAXDRT.Report
Public ConnectionInfo As CRAXDRT.ConnectionProperties
Public CRXDATABASETABLE As CRAXDRT.DatabaseTable
Dim ReportRs As New ADODB.Recordset
Set Report = Appl.OpenReport("C:\Report.rpt")
Set ConnectionInfo = Report.Database.Tables(1).ConnectionProperties
ConnectionInfo.Item("Data Source") = "Servername"
ConnectionInfo.Item("Initial catalog") = "Database"
ConnectionInfo.Item("User ID") = "***"
ConnectionInfo.Item("Password") = "***"
I've also tried the following:
For Each CRXDATABASETABLE In Report.Database.Tables
CRXDATABASETABLE.ConnectionProperties.DeleteAll
CRXDATABASETABLE.ConnectionProperties.Add "Provider", "sqloledb"
CRXDATABASETABLE.ConnectionProperties.Add "Database Type", "OLEDB (ADO)"
CRXDATABASETABLE.ConnectionProperties.Add "Data source", "Servername"
CRXDATABASETABLE.ConnectionProperties.Add "Initial Catalog", "Database"
CRXDATABASETABLE.ConnectionProperties.Add "user id", "***"
CRXDATABASETABLE.ConnectionProperties.Add "password", "***"
Next CRXDATABASETABLE
Report.DiscardSavedData
Set ReportRs = Conn.Execute("Select " & SQLSelect & " from " & SQLTables & SQLWhere & SqlText)
(The SQL variables are filled correctly)
Report.Database.SetDataSource ReportRs
Report.PaperOrientation = crPortrait
CRViewer91.ReportSource = Report
CRViewer91.ViewReport
-----------
Anyone got a clue why the database in the report just won't change?
I've got 8 databases which are all similar, but they've got information from different firms... If I were to put all this data in one database I'd have to reprogram my entire program, which at this moment is not an option.
I'm trying to use 1 report for each database, so when I'm logged on to Firm A I want to see only their data and when logged on to Firm B only theirs.
For the record I'm using Crystal Reports 9 with Visual Basic 6 and an MSSQL-server.
Obviously I've made my report based on the Firm A database.
And the report works fine when I'm logged on to that database, but when I switch databases either I get nothing on my screen or I get the data from the Firm A database...
This is officially driving me insane...
Here is the code I'm using.
Public Appl As New CRAXDRT.Application
Public Report As New CRAXDRT.Report
Public ConnectionInfo As CRAXDRT.ConnectionProperties
Public CRXDATABASETABLE As CRAXDRT.DatabaseTable
Dim ReportRs As New ADODB.Recordset
Set Report = Appl.OpenReport("C:\Report.rpt")
Set ConnectionInfo = Report.Database.Tables(1).ConnectionProperties
ConnectionInfo.Item("Data Source") = "Servername"
ConnectionInfo.Item("Initial catalog") = "Database"
ConnectionInfo.Item("User ID") = "***"
ConnectionInfo.Item("Password") = "***"
I've also tried the following:
For Each CRXDATABASETABLE In Report.Database.Tables
CRXDATABASETABLE.ConnectionProperties.DeleteAll
CRXDATABASETABLE.ConnectionProperties.Add "Provider", "sqloledb"
CRXDATABASETABLE.ConnectionProperties.Add "Database Type", "OLEDB (ADO)"
CRXDATABASETABLE.ConnectionProperties.Add "Data source", "Servername"
CRXDATABASETABLE.ConnectionProperties.Add "Initial Catalog", "Database"
CRXDATABASETABLE.ConnectionProperties.Add "user id", "***"
CRXDATABASETABLE.ConnectionProperties.Add "password", "***"
Next CRXDATABASETABLE
Report.DiscardSavedData
Set ReportRs = Conn.Execute("Select " & SQLSelect & " from " & SQLTables & SQLWhere & SqlText)
(The SQL variables are filled correctly)
Report.Database.SetDataSource ReportRs
Report.PaperOrientation = crPortrait
CRViewer91.ReportSource = Report
CRViewer91.ViewReport
-----------
Anyone got a clue why the database in the report just won't change?