How to change databas name or path in VB or Access
How to change the database which binding to the report?
for example, when I design the report, the report is bind to "customer" table in test1.mdb, when I run the report, I want to change the database to test2.mdb or other path, how can I do, anyone can give me the code of visual basic, thks in advance.
for example, when I design the report, the report is bind to "customer" table in test1.mdb, when I run the report, I want to change the database to test2.mdb or other path, how can I do, anyone can give me the code of visual basic, thks in advance.
Comments
HKEY_LOCAL_MACHINE\SOFTWARE\Fast Reports\Connections
and here you can see all the connections used. Find your connection name and connection string here and at run time just change these properties....
Note that you must change these settings in registry before you execute any code associated with the fast report engine.
This trick can also be used when distributing your final application to your customers. Fast Report Studio uses this registry location for all the connections you use during report creation.
Yes, you are right. In addition, in latest version we also use HKEY_CURRENT_USER\SOFTWARE\Fast Reports\Connections registry key, because Windows Vista does not allow to users write to HKEY_LOCAL_MACHINE.
Another solution would be to find TfrxADODatabase object and change its property 'DatabaseName'. For example:
Dim database_obj As TfrxADODatabase
' Find database object
Set database_obj = report.FindObject("ADODatabase1")
If database_obj Is Nothing Then
MsgBox "ADO connection object 'ADODatabase1' not found"
Else
Rem MsgBox "ADO connection string: " + Trim$(database_obj.ConnectionString)
' You can set connection string instead of showing it.
End If
Set database_obj = Nothing