Solved

Urgent!! Package and Deployment of VB6 project with Crystal report

Posted on 2004-07-29
8
600 Views
Last Modified: 2008-01-09
Hello. I created an installer of my VB6 project with crystal report on it. After installing it to other computer (not my computer where I developed it), I get an error "Physical database not found, logonserver errors,file not found" and so on. Actually I already encounter this kind of error, and I already fix it, but now I dont know why is this happening again. I fix this before when I dont have any subreport on my crystal report, and I think there something to do with my database path in my subreports.

In my VB6 project, I had a crystal report on it, I created my main report in vb6 and not in crystal report, but my subreports, I created them in crystal report and use Visual basic to add subreport to my project.

And during my package and deployment, I did include those .rpt(which I use in my subreport). And still there has a problem.

I also use this code inside my form where the CRViewer is in place:

Private Sub Form_Load()                   'to specify the path of my database to the main report

Set mrs = New ADODB.Recordset
sql = "Select * from Table1 ORDER BY ItemNo"

mrs.Open sql, cn, adOpenStatic, adLockOptimistic

    For i = 1 To crxReport.Database.Tables.count
        crxReport.Database.Tables(i).SetLogOnInfo "sql server", "database", "usernm", "password"
    Next

    With crxReport
          .DiscardSavedData
          .Database.SetDataSource mrs
    End With

If printselect = 1 Then
   crxReport.RecordSelectionFormula = "{ado.ItemNo} =" & "'" & (rs!ItemNo) & "'"
Else
   crxReport.RecordSelectionFormula = ""
End If

      CRViewer1.ReportSource = crxReport
      CRViewer1.ViewReport
      CRViewer1.EnableGroupTree = False
      CRViewer1.Zoom 100
       
       While CRViewer1.IsBusy
         DoEvents
       Wend

End Sub

Please Help. Tnx in advance
0
Comment
Question by:bawasi
[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
  • 4
  • 4
8 Comments
 

Author Comment

by:bawasi
ID: 11675096
I found out that the subreports are really the one causing the problem. So I think the solution is, apply that code to the subreports, but I dont know how. pls help.
0
 
LVL 42

Accepted Solution

by:
frodoman earned 400 total points
ID: 11675993
You need to provide logon information for your subreports - similar to what you're doing for your main reports in the 'tables' loop.

Some sample code here: http://support.businessobjects.com/library/kbase/articles/c2014062.asp

HTH

frodoman
0
 

Author Comment

by:bawasi
ID: 11676229
Yes I understand the code, but how will I change the database path of the subreports? To my main report, I specify the connection string of my database just like this:

Set mrs = New ADODB.Recordset
sql = "Select * from Table1 ORDER BY ItemNo"

mrs.Open sql, cn, adOpenStatic, adLockOptimistic

    For i = 1 To crxReport.Database.Tables.count
        crxReport.Database.Tables(i).SetLogOnInfo "sql server", "database", "usernm", "password"
    Next

    With crxReport
          .DiscardSavedData
          .Database.SetDataSource mrs
    End With

How can I do it to the subreports specifying my sql statement and connection strings.
0
[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

 
LVL 42

Expert Comment

by:frodoman
ID: 11676299
Did you look at the link?

Basic process is this:

Loop through each section of the main report
   Loop through each object in the section
      If this object is a subreport then
         Loop through tables in subreport
            Apply setlogoninfo method
         End loop
      End if
   End loop
End loop

Does that help or did I not understand what you're asking?

frodoman
0
 

Author Comment

by:bawasi
ID: 11676479
This is now my new Form_Load:

Private Sub Form_Load()
Dim Report As New CrystalReport1
Dim crxTables As CRAXDRT.DatabaseTables
Dim crxTable As CRAXDRT.DatabaseTable
Dim crxSections As CRAXDRT.Sections
Dim crxSection As CRAXDRT.Section
Dim crxSubreportObj As CRAXDRT.SubreportObject
Dim crxReportObjects As CRAXDRT.ReportObjects
Dim crxSubreport As CRAXDRT.Report
Dim ReportObject As Object

Form3.Left = 0
Form3.Top = 0
Form3.WindowState = 2

Set mrs = New ADODB.Recordset
Set Hrs = New ADODB.Recordset
sql = "Select * from Table1 ORDER BY ItemNo"
hsql = "Select * from PicOtherHeadTbl"                              'I add this for the path of subreport

mrs.Open sql, cn, adOpenStatic, adLockOptimistic
Hrs.Open hsql, cn, adOpenStatic, adLockOptimistic               'I add this for the path of subreport

    For i = 1 To crxReport.Database.Tables.count
        crxReport.Database.Tables(i).SetLogOnInfo "sql server", "database", "usernm", "password"
    Next

    With crxReport
          .DiscardSavedData
          .Database.SetDataSource mrs
    End With

Set crxSections = Report.Sections


For Each crxSection In crxSections
  Set crxReportObjects = crxSection.ReportObjects
  For Each ReportObject In crxReportObjects
    If ReportObject.Kind = crSubreportObject Then
      Set crxSubreportObj = ReportObject
     Set crxSubreport = crxSubreportObj.OpenSubreport

     crxSubreport.Database.Tables(1).SetLogOnInfo "sql server", "database", "usernm", "password"

     crxSubreport.DiscardSavedData                           'this doesn't work
     crxSubreport.Database.SetDataSource Hrs           'this doesn't work

     End If
  Next ReportObject
Next crxSection

If printselect = 1 Then
   crxReport.RecordSelectionFormula = "{ado.ItemNo} =" & "'" & (rs!ItemNo) & "'"
Else
   crxReport.RecordSelectionFormula = ""
End If

      CRViewer1.ReportSource = crxReport
      CRViewer1.ViewReport
      CRViewer1.EnableGroupTree = False
      CRViewer1.Zoom 100
       
       While CRViewer1.IsBusy
         DoEvents
       Wend
End Sub

I can't seem to change the datasource of the Subreport. I even try to copy the whole file of my vb project and paste to a temporary folder for trial and error: Example:

Original path:
C:\VbProject\Version1
Database path
C:\VBproject\Version1\db.mdb

New Path:
C:\VbProject\Version2
Database path
C:\VBproject\Version2\db.mdb

but it was funny that my subreport database path is reading the database at "C:\VBproject\Version1\db.mdb" and not the "C:\VBproject\Version2\db.mdb".

Thats why I want to specify the dbase path of the subreports during runtime.
0
 
LVL 42

Expert Comment

by:frodoman
ID: 11676562
    crxSubreport.DiscardSavedData                           'this doesn't work
     crxSubreport.Database.SetDataSource Hrs           'this doesn't work

As far as I know you don't need these lines of code at all - subreport shouldn't require the discard method.

Also you may want to change this:
   crxSubreport.Database.Tables(1).SetLogOnInfo "sql server", "database", "usernm", "password"

To this:

    For i = 1 To crxSubeport.Database.Tables.count
        crxSubReport.Database.Tables(i).SetLogOnInfo "sql server", "database", "usernm", "password"
    Next

This will make sure you get all of the tables if there are multiples.

Hopefully that'll do it for you.  I'm going to be offline for the most of the remainder of today but I'll check back tonight or tomorrow if you still need help.

frodoman
0
 

Author Comment

by:bawasi
ID: 11690125
I finally got it frodoman. I change this line

Set crxSections = Report.Sections

to this line -> Set crxSections = crxReport.Sections

crxReport is my main "New CrystalReport1"

and also I added this code:

crxSubreport.Database.SetDataSource Hrs

to change the database path of Subreports.

Thanks again for your help.
0
 
LVL 42

Expert Comment

by:frodoman
ID: 11692677
Glad to help - frodoman
0

Featured Post

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

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…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

724 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