Crystal Reports Data Source in Visual Studio
Using Visual Studio 2005 with the default installation of Crystal Reports.
When I create a report, Crystal queries the database and I give it my design db. In the application, I create a DataTable and pass it to the report, which is then passed to the CR viewer. At runtime, neither the report object nor the viewer should see the db, since I already got the table.
When the app is handed over to users, everything works fine. They cannot see the development of the db.
Once in the production office, I created a report on the production site, and instead of creating a Crystal Report specifying the development db, I gave it the production db. Back at his office working in VS, the report tries to connect to db development and fails. (It can't be seen.)
So it is not a problem that they cannot see my development database, but the problem is that I cannot see the production database.
Questions: Is this because launching in VS is different from launching an installed application? Why is the report trying to connect to the DB anyway? How can I control it?
source to share
I think I am following ...
When looking at .rpt in VS, right click on the database fields in the field explorer window and navigate to Set Data Source Location. What does it show for your connection? Does it point to the db Production server? This setting will be saved in the .rpt file so that it can explain your problem.
source to share
Questions: Is this because launching in VS is different from launching an installed application? Why is the report trying to connect to the DB anyway? How can I control it?
you can manage it according to the content of your report
if your report contains one table and you have passed that table to your report using DataTable the report will work fine
but report will try to connect to the original DB location when your data table does not provide all the report data, usually when your report contains two or more tables
in this case you need to pass DATASET for a report containing all tables
here is my code using 2 tables create authors and titleauthor
'Build a SQL statement to query for the authors table
Dim sqlString As String = "SELECT * FROM authors"
'Retrieve the data using the SQL statement
adoOleDbDataAdapter = New OleDbDataAdapter(sqlString, adoOleDbConnection)
'Build a SQL statement to query for the titleauthor table
sqlString = "SELECT * FROM titleauthor"
'Retrieve the data using the SQL statement
adoOleDbDataAdapter2 = New OleDbDataAdapter(sqlString, adoOleDbConnection)
'Create a instance of a Dataset
DataSet1 = New DataSet()
'Fill the dataset with the data with author information
adoOleDbDataAdapter.Fill(DataSet1, "authors")
'Fill the dataset with the data with titleauthor information.
'The table name used in the Fill method must be identical to the name
'of the table in the report.
adoOleDbDataAdapter2.Fill(DataSet1, "titleauthor")
'Pass the dataset to the report
crReportDocument.Database.Tables(0).SetDataSource(DataSet1)
'View the report
CrystalReportViewer1.ReportSource = crReportDocument
source to share