Results 1 to 3 of 3

Thread: Changing database location in Crystal Report. [Resolved]

  1. #1

    Thread Starter
    Registered User
    Join Date
    Apr 2003
    Location
    Klang, Selangor, Malaysia
    Posts
    163

    Changing database location in Crystal Report. [Resolved]

    Currently the database location of my Crystal Report is "C:\Invoice\Database.mdb"

    I would like to change it to this:

    Application.Startup & "\Database\Database.mdb"

    So that, if I move my Invoice project's folder to other location, I can still run the Crystal Report, without changing the database path.

    How can I make it?

    Please guide. Thank you.
    Last edited by albertlse; Aug 21st, 2003 at 08:29 PM.

  2. #2
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    Inside an event put this:
    VB Code:
    1. Dim rpt As New crTest() ' Your report name
    2. Dim tb As CrystalDecisions.CrystalReports.Engine.Table
    3. Dim cn As New CrystalDecisions.Shared.ConnectionInfo()
    4. cn.DatabaseName = Application.StartupPath & Application.Startup & "\Database\Database.mdb"  ' The path
    5. cn.UserID = "username" 'may not be needed
    6. cn.Password = "yourpassword" 'may not be needed
    7. '  cn.ServerName = "The_Server_Path_If_Needed"
    8. Dim tblog As New CrystalDecisions.Shared.TableLogOnInfo()
    9. For Each tb In rpt.Database.Tables
    10. tblog.ConnectionInfo = cn
    11. tb.ApplyLogOnInfo(tblog)
    12. Next
    13. rptv.ReportSource = rpt ' rptv is your crystal report viewer
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  3. #3

    Thread Starter
    Registered User
    Join Date
    Apr 2003
    Location
    Klang, Selangor, Malaysia
    Posts
    163
    it's working fine now!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width