Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 531
  • Last Modified:

CRYSTAL REPORTS 9 -SET DATA SOURCE LOCATION PROBLEM

query regarding CRYSTAL REPORTS 9:
actually what i needed is,when adding any database fields in the design view.when i see the sql

query dialog box automatically,the database name gets added in front of the tables .so the

problem is when i change the database ,the report gives error like "field names not known"
0
ashok_btech
Asked:
ashok_btech
3 Solutions
 
EwaldLCommented:
using the set location command in the crystal reports designer you shouldnt have any problem changing the database. this should be done for you. so i assume you are changing the database at runtime? if so, you need to change the table location. here is some vb6 / rdc 9 code that should take care of this. i hope this helps, but let me know in case i misunderstood the question or in case you are using some other object model

Dim myReport As CRAXDRT.Report
Dim myTable As CRAXDRT.DatabaseTable
For Each myTable In myReport.Database.Tables
  myTable.ConnectionProperties("Data Source") = "NewSqlServer"
  myTable.ConnectionProperties("Database") = "newDatabase"
  myTable.ConnectionProperties("Password") = "ThePassword"
  myTable.ConnectionProperties("User ID") = "TheUser"
  myTable.Location "NewDatabase.dbo." + myTable.Name
Next
0
 
yuniarCommented:
This problem has been fixed in Crystal Reports patch.
Have you deploy Crystal Report 9 patch?
0
 
yadav_surenderCommented:
For setting the databaes at runtime use the following code

First declare the recordset of that table which you are using the report
then write the following code
Report.Database.SetDatasource rs,3,1  'rs is the recordset of that  table which you are using

If you are using more than one table then you can use another recordset
Report.Database.SetDatasource rs23,2 'rs2 the recordset of thoe second table

Cheers
Surender
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now