You can of course change from an ODBC, a DNS, Oracle to SQL or Exchange I really is up to you. This stores the necessary credentials, server and database to connect to.
To ensure that the object is referencing the right database at run-time, we will need to update this we do this by using the TableLogOnInfo object. Each object references the database connection of the document. Each report is split into objects, an object can be a data table, a graph or a sub report (there are others – but I am only demonstrating the first two). Me.crvReportViewer.ReportSource = crReportDocumentīefore the report can be loaded, it needs to have the datasources of the main report document and each of the sub reports too updated to that of the application. ' Set the Report Viewer's source to be the Report Document ' Set the parameters to be passed to the report SetDBLogonForSubreports(m圜onnectionInfo, crReportDocument)
' Set the database logon for the sub reports SetDBLogonForReport(m圜onnectionInfo, crReportDocument) M圜onnectionInfo.IntegratedSecurity = True M圜onnectionInfo.DatabaseName = My.Settings.Database M圜onnectionInfo.ServerName = My.Settings.Server The routine will configure the database connection and apply this to the report document.ĭim m圜onnectionInfo As ConnectionInfo = New ConnectionInfo() Now you will need to set the properties for how the report connects to your database, I show you here in one procedure call LoadReport(). Private Sub frmReports_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load ' Used to store the report document (the. Then you need to load your report, here it is done at the form load event. So create a new form and import the following Crystal references: Oh and of course that you have a control to display the report document called crvReportViewer. The assumptions here are that you are on a Windows domain, you store your server and database in the My.Settings properties of the project and that all of the data used in a report is returned from the same database.
The example below shows you how to load the report, configure it and display it on your form. So I thought lets do this at run-time.ĭoing this at run-time ensures that you are connecting to the same database as the main application is using, so no chance of reporting on your development database for production data.
This is great for doing the simple things with little hastle at all and also doing the really complicated stuff without too much referring to a help manual either.īut what happens when you find that you have created dozens of them in your development environment and now need to move this to production? I had this trouble and started on the manual process of using the “Set Datasource Location…”, but why do the same action multiple times, because remember that you will have to do the same in reverse when you want to go back to developing. Right? Well,the choice of many is to go for Crystal Reports. If you have a database, you more than likely want to query it and present the data.