Results 1 to 5 of 5

Thread: Changing MSAccess databases in Crystalreports .net at run time

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2003
    Posts
    13

    Changing MSAccess databases in Crystalreports .net at run time

    I am tring to change the database at runtime using crystal reports .net. I can dot it with SQL Server using the report.SetDatabaseLogIn and the TableLogOnInfo.
    But how do I do it with access? There doesn't seem a way to do it with local databases.

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    I don't know how to specifically answer your question, but I will help you out in dealing with Crystal Reports. After having a co-worker troubleshooting Crystal problems for over two weeks, he figured out the most easy way to deal with Crystal Reports.

    The secret is using Strongly Typed DataSets as the datasource. In code, you fill the Strong Typed DataSet, and then you set the source of the report to that. After we switched to doing that, our reports ran faster, and they didn't cause us all the security headaches we had before.

    The best part would be that in your situation, it wouldn't matter from where the data came from to populate the dataset, the report wouldn't care at all as long as there is data in the dataset that matches the report requirements.

    Good luck, and sorry that I couldn't help you specifically.

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2003
    Posts
    13
    I need to change the access database at runtime.
    This used to be done with datafiles property.
    Can you do it in .NET?

  4. #4
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    If you mean you need to change database on which the report is based, this may help you. If your report is called myReport and the CR viewer is called CRV then:
    VB Code:
    1. Dim rpt As CrystalDecisions.CrystalReports.Engine.ReportDocument
    2. Dim tbl As CrystalDecisions.CrystalReports.Engine.Table
    3. rpt = New myReport
    4. For Each tbl In rpt.Database.Tables
    5.       Dim tbllogin As New CrystalDecisions.Shared.TableLogOnInfo
    6.       tbllogin.ConnectionInfo.UserID = "admin"
    7.       tbllogin.ConnectionInfo.Password = "password_here"
    8.       tbllogin.ConnectionInfo.DatabaseName = "path_to_db_here"
    9.       tbl.ApplyLogOnInfo(tbllogin)
    10. Next
    11. CRV.ReportSource = rpt
    '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

  5. #5
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Dublin (Ireland)
    Posts
    304
    www.crystalreportsbook.com

    this url steps you through the whole process, especially chapter 14

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