[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 345
  • Last Modified:

Dynamically Linking reports for our customers

Hi, my first question as a newly joined member

we have developed an application running on sql server, vb6 using crystal 8.5

what would be the best way to distribute the reports to our customers and relink to their respective databases through code rather than how we do presently - we relink the reports manually through a remote dial up connection from our support desk

have looked at a quite a lot of previously asked questions but its seems that unless we pass recordsets through to the reports (which we will probably move to over time) there is not any other choice open to us

Cheers
0
consultsgp
Asked:
consultsgp
  • 6
  • 5
  • 3
2 Solutions
 
vidruCommented:
Here's an approach I've used for several applications:

In the path of the application, there resides a Reports folder containing the .rpt files.  At runtime, a Reports menu is created dynamically, adding each report found in the Reports folder as a menu item.  When a report menu item is clicked, a Report object is created and sent to a VB form with a CRViewer component.  In the Viewer form's code, you can re/set the report's logon info at runtime (for a code sample, see http://www.tek-tips.com/faqs.cfm?fid=5374).

Using this method, you'd only have to transfer over the .rpt files, and the application would take care of the 'linking' at runtime.

-dave
0
 
consultsgpAuthor Commented:
Hi Dave

Have followed this to the letter but my system comes up with a system error
&H80004005 (-2147467259)?

Any ideas as to what could cause this - is it a license issue even though I have the Crystal 8.5 developers license?

Cheers
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
vidruCommented:
Is the error message any more specific than that?  If you step through the code, what causes the error?

If you can, post the code you're using, and we'll have a look.

-dave
0
 
consultsgpAuthor Commented:
Hi Dave

Exactly as typed:
'--------------------------
Option Explicit
Dim crxApp As New Application
Dim crxRpt As CRAXDRT.Report
Dim crxTables As CRAXDRT.DatabaseTables
Dim crxTable As CRAXDRT.DatabaseTable
Dim crxSubreportObject As CRAXDRT.SubreportObject
Dim crxSubReport As CRAXDRT.Report
Dim crxSections As CRAXDRT.Sections
Dim crxSection As CRAXDRT.Section

Private Sub Form_Load()
'Variable declarations
Dim strServerOrDSNName As String
Dim strDBNameOrPath As String
Dim strUserID As String
Dim strPassword As String
Dim i As Integer, j As Integer


strServerOrDSNName = "KorrectK"
strDBNameOrPath = "KorrectK"
strUserID = "sa"
strPassword = ""

'Open the report
Set crxRpt = crxApp.OpenReport("C:\Korrect\Reports\Double Moon\025 TrackList.rpt")

'Set the connection for the report.
crxRpt.Database.Tables(1).SetLogOnInfo strServerOrDSNName, _
    strDBNameOrPath, strUserID, strPassword

'This removes the schema from the Database Table's Location property.
Set crxTables = crxRpt.Database.Tables
For Each crxTable In crxTables
    With crxTable
         .Location = .Name
    End With
Next

'Loop through the Report's Sections to find any subreports, _
    and change them as well
Set crxSections = crxRpt.Sections

For i = 1 To crxSections.Count
    Set crxSection = crxSections(i)

    For j = 1 To crxSection.ReportObjects.Count

        If crxSection.ReportObjects(j).Kind = crSubreportObject Then
            Set crxSubreportObject = crxSection.ReportObjects(j)

            'Open the subreport, and treat like any other report
            Set crxSubReport = crxSubreportObject.OpenSubreport
            Set crxTables = crxSubReport.Database.Tables

            For Each crxTable In crxTables
                With crxTable
                    .SetLogOnInfo strServerOrDSNName, _
                        strDBNameOrPath, strUserID, strPassword
                    .Location = .Name
                End With
            Next

        End If

    Next j

Next i

'View the report
Viewer.ReportSource = crxRpt
Viewer.ViewReport


End Sub

'--------------------------

Done this in a new project with just the following:
Components: Crystal Report Viewer Control
References: Crystal Reports 8.5 ActiveX Designer Run Time Library
Crystal Report Viewer Control

Many thanks Again
0
 
vidruCommented:
The code tests fine.

Again, if you step through the code, where does the error happen, and is it more descriptive than just the error code (-2147467259)?

-dave
0
 
consultsgpAuthor Commented:
Hi

whenever I try to save the form it just comes up with this error
0
 
anvCommented:
error occurs 'coz of duplicate values
being entered into the database...
0
 
consultsgpAuthor Commented:
Hi Anv

Getting a bit confused here as it seems to throw the error before hitting any database

We do set up the same DSN as the database name hence the KorrectK being repeated - is this what you meant?

Many thanks
0
 
consultsgpAuthor Commented:
The error happens when we try to save the form?
0
 
vidruCommented:
Try doing a Google search for: &H80004005 (-2147467259) system error visual basic

I don't know what's going on, but have a look at the search results to see if anything looks relevant.  I'm going to be in an out all day getting ready for another goofy hurricane, but I'll check in periodically.

-dave
0
 
consultsgpAuthor Commented:
Hi Dave

It is something to do with the Riched32.dll which is usually installed when exchange is implemented - given that I run remote exchange seems a bit odd but have managed to resolve the issue and your code works a treat

Thanks for all of your help and hope the hurricane does not affect anyone

Will send over the points

Cheers
Simon
0
 
vidruCommented:
Thanks Simon, and glad I could help.

-dave
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 6
  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now