?
Solved

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

Posted on 2004-07-29
8
Medium Priority
?
603 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 1200 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
Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

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. …
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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

762 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