Solved

Dynamically Linking reports for our customers

Posted on 2004-09-22
14
332 Views
Last Modified: 2012-06-27
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
Comment
Question by:consultsgp
  • 6
  • 5
  • 3
14 Comments
 
LVL 13

Assisted Solution

by:vidru
vidru earned 500 total points
ID: 12127696
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
 
LVL 10

Expert Comment

by:anv
ID: 12130637
0
 

Author Comment

by:consultsgp
ID: 12149791
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
 
LVL 10

Expert Comment

by:anv
ID: 12149799
0
 
LVL 13

Expert Comment

by:vidru
ID: 12149807
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
 

Author Comment

by:consultsgp
ID: 12149815
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
 
LVL 13

Expert Comment

by:vidru
ID: 12149858
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:consultsgp
ID: 12149934
Hi

whenever I try to save the form it just comes up with this error
0
 
LVL 10

Expert Comment

by:anv
ID: 12149944
error occurs 'coz of duplicate values
being entered into the database...
0
 

Author Comment

by:consultsgp
ID: 12150111
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
 

Author Comment

by:consultsgp
ID: 12150223
The error happens when we try to save the form?
0
 
LVL 13

Accepted Solution

by:
vidru earned 500 total points
ID: 12150583
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
 

Author Comment

by:consultsgp
ID: 12151450
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
 
LVL 13

Expert Comment

by:vidru
ID: 12151936
Thanks Simon, and glad I could help.

-dave
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

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
This video discusses moving either the default database or any database to a new volume.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

759 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

21 Experts available now in Live!

Get 1:1 Help Now