Solved

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

Posted on 2004-07-29
8
588 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
  • 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
 
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video discusses moving either the default database or any database to a new volume.

746 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