Hi All,

I would like to thank this community for the enormous help to develop my skills. Thanks.

I have 2 databases and a single report form and a crystal reportviewer.
The User can select the database which he want to work
(Each of them belongs to different warehouse)
So he can select and make dc, invoice, and associated work for the particular database.
I have a dataclass it difines which database selected and which data should be retrieved
using a login screen which contains a database selection combo. All goes well.

I am also created a report format in crystal report. and it also have parameters.
If it is a single database report i can easily connect the data thru typed dataset.

But I have 2 databases, how can i get the report source for the report
My problem is how to retrieve the data for the particular database to that crystal reports.

Please let me give some idea about getting the particular database data for the report.
Thanks in advance.....

Please confirm that I understand.

If I understand correctly, you can:

  1. Determine which database to connect.
  2. Connect to either database per user choice in ComboBox.
  3. Retrieve the correct data.
    All at runtime

Is that correct?

hi john,
I am very sorry for my late answer.
Your view is absolutely correct.
When the application startsup the user has signed in and after that they have selected the database (i.e: 10462.mdb, 61973.mdb etc). After that I have a connected thru a connection class using the current database. Its working fine. But I don't know how to use the same method in crystal reports.

When you set the database connection string, set a global variable for crystal reports at the same time

Something like:

If storeChosen =  10462 Then
    connectionstring = YOUR_DATABASE_10462_CONNECTION_STRING
    crystalReportVer = VERSION_10462
ElseIf storeChosen = 61973 Then
    connectionstring = YOUR_DATABASE_61973_CONNECTION_STRING
    crystalReportVer = VERSION_61973
Else
    MsgBox("Unable to get store & db version")
End If

Then when it's time to print the crystal report, you just use that variable to determine which datasource to set for the report. There is a thread here, discussing setting the datasource programatically, that also references some KB articles at Crystal's website.

Disclaimer: I don't use Crystal Reports, so I don't have that code on-hand

Thanks john.

My pleasure

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.