Solved

Dynamically Linking reports for our customers

Posted on 2004-09-22
14
341 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

 
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
 

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

726 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