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.

Comments

  • edited 2:08PM
    Fast Report Studio stores all the connections that it uses in the windows registry. To have a look at it just go to :
    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.

    ;)
  • edited 2:08PM
    Fast Report Studio stores all the connections that it uses in the windows registry. To have a look at it just go to :
    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.... [img]style_emoticons/<#EMO_DIR#>/wink.gif" style="vertical-align:middle" emoid=";)" border="0" alt="wink.gif" /> 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.[/img]

    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


Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.