Access World Forums

Access World Forums (https://www.access-programmers.co.uk/forums/index.php)
-   Crystal Reports (https://www.access-programmers.co.uk/forums/forumdisplay.php?f=65)
-   -   Coding for connection and data binding (https://www.access-programmers.co.uk/forums/showthread.php?t=304954)

Ryobi 05-04-2019 09:29 PM

Coding for connection and data binding
 
Hello,


I am using Vb.net 2017. I have created a crystal report and connected an msaccess database to the report and have added fields using the connection on the crystal report. I would like to code the connection my self since the I want the database to place in different place in case I want to put in different folders.
The problem that I have is where do I put the code. I do not see any where on the crystal report form where I can place the code. Any ideas or suggestions are welcome.


Thank

Ryobi 05-07-2019 06:52 PM

Re: Coding for connection and data binding
 
In case somebody is wondering how is done the code is shown below:

Dim cr As New CrystalReport1
cr.Load(strReportPath)
cr.SetDataSource(ds.Tables("Mytable"))

CrystalReportViewer1.ReportSource = cr

CrystalReportViewer1.Refresh()


Place above code at the load event of the Crystal Report Viewer Form.


Note: The code for loading and extracting data from the database is not shown,
but a connection to the database must be made in order to load the data into the ds.table
other wise you will get an an error because ds.Table is not defined.


All times are GMT -8. The time now is 12:04 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World