Click here to Skip to main content
16,019,273 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All,
I have a problem with changing database for crystal report.
I have design a report using crystal report by using DSN as a data source.
I have two databases such as aces_database and aces_database_2.
When I log into the branch1, the report will take data from aces_database.
but when I log into branch2, I can make my DSN change database to aces_database_2
but the it still take data from branch1.
I have the method to change it in design view. but I couldn't find the way to change it by code.

How could I configure to change database for crystal report using vb.net?
Posted
Comments
DamithSL 14-May-14 1:06am    
can't you create another DSN for aces_database_2?
Thynin ITE 14-May-14 7:27am    
If I create another DSN for that, how could I take my report to get data from that DSN?
Dave Kreskowiak 14-May-14 8:59am    
The first thing you should be asking is why you're even using a DSN. A DSN is nothing but a text file with the data to create a connection string. This is something you can do in your own code with very simple string manipulation without ever touching a DSN.

1 solution

Hi, This is how I have done it in the past


VB
Dim rptDriver as new ReportDocument
'... Load the report ect.
rptDriver.DataSourceConnections.Item(0).SetConnection(gDataBaseName, g_dbConn.Database, gUserID, gPWD)
rptDriver.Refresh
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900