• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 615
  • Last Modified:

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

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
bawasi
Asked:
bawasi
  • 4
  • 4
1 Solution
 
bawasiAuthor Commented:
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
 
frodomanCommented:
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
 
bawasiAuthor Commented:
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
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
frodomanCommented:
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
 
bawasiAuthor Commented:
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
 
frodomanCommented:
    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
 
bawasiAuthor Commented:
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
 
frodomanCommented:
Glad to help - frodoman
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now