Solved

Programmatically setting data source location of a Crystal Report to MS Access database

Posted on 2007-11-18
9
1,537 Views
Last Modified: 2013-11-07
Hi Experts,

I have several Crystal Report XI reports that I automate through VB.Net.  These reports point to an Access database.  I need to store the path to the access database mdb file as a setting and then set the data source location at run-time with my VB code.

How do I do this?

Thanks
0
Comment
Question by:PantoffelSlippers
  • 5
  • 2
  • 2
9 Comments
 
LVL 4

Expert Comment

by:habibb
Comment Utility
0
 

Author Comment

by:PantoffelSlippers
Comment Utility
Hi Habibb,

That's not exactly what I was looking for.  That example uses VB6 with the CRXDRT DLL which I've used a lot in the past.  What I'm trying to do with Access now I can already do with SQL Server, see example below:

  Public Sub SetReportConnections(ByRef XReport As ReportDocument)
    Dim CInfo As New ConnectionInfo
    Dim t As Table
    Dim TLogonInfo As TableLogOnInfo
    Dim SubR As New ReportDocument


    'Set the connection
    CInfo.ServerName = ServerName
    CInfo.DatabaseName = DatabaseName
    CInfo.UserID = UserID
    CInfo.Password = Password

    'Set Logon details for main report and each table inside the main report
    For Each t In XReport.Database.Tables
      TLogonInfo = t.LogOnInfo
      TLogonInfo.ConnectionInfo = CInfo
      t.ApplyLogOnInfo(TLogonInfo)
    Next

    For Each SubR In XReport.Subreports
      For Each t In SubR.Database.Tables
        TLogonInfo = t.LogOnInfo
        TLogonInfo.ConnectionInfo = CInfo
        t.ApplyLogOnInfo(TLogonInfo)
      Next
    Next

  End Sub


This procedure explicitly sets the connection details for a report file that connects to SQL Server.  Now I need to do exactly the same with MS Access but I'm assuming that different objects / properties / methdos must be used.

From the example in the link I basically need to copy the following logic:
Dim CRXDatabase As CRAXDRT.Database
Set CRXDatabase = CRXReport.Database
CRXDatabase.SetDataSource rs, 3, 1

I'm not using the CRXDRT so this syntax won't work.  I can't find the syntax to perform this logic. I need to find the exact syntax for the components that I'm using.  I'm using the CrystelDecisions .Net references.

Thanks
0
 
LVL 4

Expert Comment

by:habibb
Comment Utility
0
 

Author Comment

by:PantoffelSlippers
Comment Utility
Thanks habibb,

From the example provided I got the following:

cr1.ReportFileName = App.Path & "\reports\ot1.rpt"
cr1.DataFiles(0) = App.Path & "\otmanag.mdb"

I'm assuming that cr1 is a ReportDocument?  My reportdocument doesnt have a DataFiles property.  I assume the example also uses a different version of the Crystal API than I am.  As in the very first example, this is exactly the logic that I'm trying to perform, only the syntax doesn't fit my API.

Is there perhaps an API guide for the Crystal Reports XI R2 .Net references?

Thanks
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 4

Accepted Solution

by:
stcindia earned 500 total points
Comment Utility
Please find below information copied from http://diamond.businessobjects.com/node/134
If you are connecting to Access through OLE DB,
then set the 'ServerName':

With crConnectionInfo
.ServerName = "C:\mydatabase\mydata.mdb"
End With
0
 

Author Comment

by:PantoffelSlippers
Comment Utility
Thanks stcindia,

I'll try this immediately
0
 

Author Closing Comment

by:PantoffelSlippers
Comment Utility
         Dim CInfo As New ConnectionInfo
          Dim TlogonInfo As TableLogOnInfo
          Dim t As Table

          CInfo.ServerName =

          For Each t In crRepDoc.Database.Tables
            TlogonInfo = t.LogOnInfo
            TlogonInfo.ConnectionInfo = CInfo
            t.ApplyLogOnInfo(TlogonInfo)
          Next
0
 

Author Comment

by:PantoffelSlippers
Comment Utility
Thank you stcindia
0
 
LVL 4

Expert Comment

by:stcindia
Comment Utility
Glad I could help
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now