URGENT : CRPE32 (CR8), Subreport And Changing Server (with SQL Server 7.0) 
Author Message
 URGENT : CRPE32 (CR8), Subreport And Changing Server (with SQL Server 7.0)

Hello,

I would like to know how to change the server of the Database defined in a
Report Which contains SubReports.

I have used PESetNthTableLogOnInfo on the primary report and on all the
subreport that can exist but an error "599- Cannot find the server SQL."
always appears when i used Report with Subreport.

If someone have an idea to solve this problem, i listen him

Thanks in advance

Woodstock



Mon, 08 Dec 2003 00:06:03 GMT  
 URGENT : CRPE32 (CR8), Subreport And Changing Server (with SQL Server 7.0)
Hi I believe you will encounter more problems than just this

Firstly you have to dim the report within your application using the
craxdrt.
Once this has been done you will then be able to change the server etc,
however you will have to connect the report to the database as well.  This
will involve connecting both the main report and the subreports via a
connection string.

You can do this by looping through the various sections of the report and
checking for the type of object ie Subreport object.

This is easy enough once you have done it and there is also an article on
the seagate site.

Malcolm

Quote:
> Hello,

> I would like to know how to change the server of the Database defined in a
> Report Which contains SubReports.

> I have used PESetNthTableLogOnInfo on the primary report and on all the
> subreport that can exist but an error "599- Cannot find the server SQL."
> always appears when i used Report with Subreport.

> If someone have an idea to solve this problem, i listen him

> Thanks in advance

> Woodstock



Mon, 08 Dec 2003 22:31:20 GMT  
 URGENT : CRPE32 (CR8), Subreport And Changing Server (with SQL Server 7.0)
I have found

I do not develop with VB but with Centura. The call of the functions is the
same in the two language.

I give you a part of my Code for people who want to "use" Crystal Report

The source code use crpe32.dll
LIMITATION: The Code only accept String parameters.

What you can do with this source code :
* Use String Parameters
* Change Server/Database/User/Password (with subreport if you want)
* Change the query (where/Order)

Some comments can be in French ! Sorry, i have not the time to change them.

Youy will first find a function which is called from the preview and then
functions to drive CR8.0
Hope it will be Helpfull !!

Woodstock

! At the creation of the document (which serve to preview)

Function: OnCreateComplete

 Local variables

  Number: nXT

  Number: nYT

  Number: nXB

  Number: nYB

  !

  Boolean: bTree

  Boolean: bCanDrillDown

  Boolean: bNavigationButtons

  Boolean: bCancelButton

  Boolean: bPrintButton

  Boolean: bExportButton

  Boolean: bZoomControl

  Boolean: bCloseButton

  Boolean: bProgressControls

  Boolean: bSearchButton

  Boolean: bPrintSetupButton

  Boolean: bRefreshButton

 Actions

  If nModeImpression = CRYSTAL_PrintPreview

   Call GetClientRect ( hWndForm, nXT, nYT, nXB, nYB )

  Call fnInit( )

  Call fnSetLogonDefaults ( NomServeur , NomDatabase , NomUser ,
NomPassword)

  Set striReportFileName = AppDirectoryRapports || NomRPT

  Call fnOpen( )

  If nModeImpression = CRYSTAL_PrintPreview

   Loop Gestion des flags

    Set bTree = ( nFlags & CRYSTAL_Tree = CRYSTAL_Tree )

    Set bCanDrillDown = ( nFlags & CRYSTAL_CanDrillDown =
CRYSTAL_CanDrillDown )

    Set bNavigationButtons = ( nFlags & CRYSTAL_NavigationButtons =
CRYSTAL_NavigationButtons )

    Set bCancelButton = ( nFlags & CRYSTAL_CancelButton =
CRYSTAL_CancelButton )

    Set bPrintButton = ( nFlags & CRYSTAL_PrintButton =
CRYSTAL_PrintButton )

    Set bExportButton = ( nFlags & CRYSTAL_ExportButton =
CRYSTAL_ExportButton )

    Set bZoomControl = ( nFlags & CRYSTAL_ZoomControl =
CRYSTAL_ZoomControl )

    Set bCloseButton = ( nFlags & CRYSTAL_CloseButton =
CRYSTAL_CloseButton )

    Set bProgressControls = ( nFlags & CRYSTAL_ProgressControls =
CRYSTAL_ProgressControls )

    Set bSearchButton = ( nFlags & CRYSTAL_SearchButton =
CRYSTAL_SearchButton )

    Set bPrintSetupButton = ( nFlags & CRYSTAL_PrintSetupButton =
CRYSTAL_PrintSetupButton )

    Set bRefreshButton = ( nFlags & CRYSTAL_RefreshButton =
CRYSTAL_RefreshButton )

     Set bRefreshButton = FALSE

    Break

   !     Preview

Call fnPrintPreview ( striReportFileName,stTitre,  nXT, nYT, nXB, nYB,
WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_BORDER, hWndItem )

   Call fnSetWindowOptions ( bTree, bCanDrillDown, bNavigationButtons,
bCancelButton, bPrintButton, bExportButton, bZoomControl, bCloseButton,
bProgressControls, bSearchButton, bPrintSetupButton, bRefreshButton )

   Call PEZoomPreviewWindow( niJobNo, PE_ZOOM_SIZE_FIT_ONE_SIDE)

   Call fnRefresh ( )

   Call SalSetWindowText ( hWndForm, stTitre || ' - [ ' || NomRPT || ' ]')

  Else

   Call fnPrint ( NomRPT , NbCopies)

   Call SalDestroyWindow( hWndForm )

The general functions

Form Window Class: clsfrmCrystalReport

Instance Variables

  Window Handle: hWndReport

  String: stReportName

  Boolean: bOk

  Number: niJobNo

  Boolean: biOK

  String: striServer

  String: striDBName

  String: striUser

  String: striPassword

  String: striReportFileName

  Number: niJobNoSubreport[*]

  Number: nSubreportHandle[*]

  Number: nNbniJobNoSubreport

 Functions

  Function: OnSize

   Description:

   Returns

   Parameters

   Static Variables

   Local variables

    Number: nXT

    Number: nYT

    Number: nXB

    Number: nYB

   Actions

    If hWndReport != hWndNULL and SalGetWindowState ( hWndReport ) !=
Window_Invalid

     Call GetClientRect ( hWndForm, nXT, nYT, nXB, nYB )

     Call SetWindowPos ( hWndReport, hWndNULL, nXT, nYT , nXB, nYB,
SWP_NOZORDER | SWP_NOCOPYBITS )

  Function: fnDisplayError

   Description: This function displays the error number and text if not
biOK. This prevents the need to constantly

     test the boolean and call this function if TRUE

      The default function is very useful during development

     The Driver functions make a late bound call to this function so that a
dervided class or object w/functions

     can replace this development function

   Returns

    Boolean:

   Parameters

   Static Variables

   Local variables

    Number: nErrorCode

    Number: nTextHandle

    Number: nTextLen

    String: sError

   Actions

    If NOT biOK

     Set nErrorCode = PEGetErrorCode( niJobNo )

     Call PEGetErrorText( niJobNo, nTextHandle, nTextLen )

     Call SalStrSetBufferLength( sError, nTextLen -1)

     Call PEGetHandleString( nTextHandle, sError, nTextLen )

     Call SalMessageBox( 'An error has occurred while printing your report.

       Error Number: ' || SalNumberToStrX (nErrorCode,0) || ' ' ||  sError,
'Crystal Report Error', MB_Ok | MB_IconExclamation )

    Return biOK

  Function: fnGetNthReportParam

   Description: Set a specific Parameter

   Returns

    String: stTemp

   Parameters

    Number: npParamNumber

   Static Variables

   Local variables

    String: strName

    String: strPrompt

    String: strDefaultValue

    Number: nDefaultValueSet

    Number: nCurrentValueSet

    String: strDummy

    String: stTemp

    String: strpParamValue

    Number: npParamType

   Actions

    If biOK

     Call SalStrSetBufferLength( strName,255)

     Call SalStrSetBufferLength( strPrompt, 255 )

     Call SalStrSetBufferLength( strDefaultValue, 255 )

     Call SalStrSetBufferLength( strpParamValue, 255 )

     Set nDefaultValueSet = FALSE

     Set nCurrentValueSet = TRUE

     ! 1032 = struct size 4 Words and 4 Char 255

     Set biOK = PEGetNthParameterField( niJobNo, npParamNumber, 1032,
npParamType, nDefaultValueSet, nCurrentValueSet

       , strName,strDummy, strPrompt, strDummy, strDefaultValue, strDummy,
stTemp )

    Return strName

  Function: fnSetNthReportParam

   Description: Set a specific Parameter

   Returns

    Boolean:

   Parameters

    Number: npParamNumber

   Static Variables

   Local variables

    String: strName

    String: strPrompt

    String: strDefaultValue

    Number: nDefaultValueSet

    Number: nCurrentValueSet

    String: strDummy

    String: strpParamValue

    Number: npParamType

    String: stTemp

   Actions

    If biOK

     Call SalStrSetBufferLength( strName,255)

     Call SalStrSetBufferLength( strPrompt, 255 )

     Call SalStrSetBufferLength( strDefaultValue, 255 )

     Call SalStrSetBufferLength( strpParamValue, 255 )

     Set nDefaultValueSet = FALSE

     Set nCurrentValueSet = TRUE

     ! 1032 = struct size 4 Words and 4 Char 255

     Set biOK = PEGetNthParameterField( niJobNo, npParamNumber, 1032,
npParamType, nDefaultValueSet, nCurrentValueSet

       , strName,strDummy, strPrompt, strDummy, strDefaultValue, strDummy,
stTemp )

     !

     Call SalStrSetBufferLength( strName,255)

     Call SalStrSetBufferLength( strPrompt, 255 )

     Call SalStrSetBufferLength( strDefaultValue, 255 )

     Call SalStrSetBufferLength( strpParamValue, 255 )

     Set nDefaultValueSet = FALSE

     Set nCurrentValueSet = TRUE

     ! 1032 = struct size 4 Words and 4 Char 255

     If npParamType = PE_PF_STRING

      Set biOK = PESetNthParameterField( niJobNo, npParamNumber, 1032,
npParamType, nDefaultValueSet, nCurrentValueSet

        , strName,strDummy, strPrompt, strDummy, strDefaultValue, strDummy,
stCrystal )

     Else If npParamType = PE_PF_NUMBER

      Set stCrystal = SalNumberToStrX( nCrystal, 0 )

      Set biOK = PESetNthParameterField( niJobNo, npParamNumber, 1032,
npParamType, nDefaultValueSet, nCurrentValueSet

        , strName,strDummy, strPrompt, strDummy, strDefaultValue, strDummy,
stCrystal )

     Else

      Set stCrystal = DateToStrX( dtCrystal )

      Set biOK = PESetNthParameterField( niJobNo, npParamNumber, 1032,
npParamType, nDefaultValueSet, nCurrentValueSet

        , strName,strDummy, strPrompt, strDummy, strDefaultValue, strDummy,
stCrystal  )

    Return biOK

  Function: fnInit

   Description: Inits key class variables

   Returns

   Parameters

   Static Variables

   Local variables

   Actions

    Set biOK = TRUE ! Init OK Flag

    Set niJobNo = NUMBER_Null

  Function: fnSetLogonDefaults

   Description: Call if you need to Set the Reports Logon Parameters

     NOTE: strpServer for ODBC is the Data Source Name (DSN) as configured
using your ODBC adminstrator

   Returns

   Parameters

    String: strpServer

    String: strpDBName

    String: strpUser

    String: strpPassword

   Static Variables

   Local variables

   Actions

    Set striServer = strpServer

    Set striDBName = strpDBName

    Set striUser = strpUser

    Set striPassword = strpPassword

    ! Prepare strings to be sent to DLL functions

    Call SalStrSetBufferLength(striServer,127)

    Call SalStrSetBufferLength(striDBName,127)

    Call SalStrSetBufferLength(striUser,127)

    Call SalStrSetBufferLength(striPassword,127)

  Function: IsRptOpen

   Description: If JobNo is NULL, attempts to Open the report. If that
fails, it returns FALSE

   Returns

    Boolean:

   Parameters

   Static Variables

   Local variables

   Actions

    If niJobNo = NUMBER_Null AND biOK

     Call fnOpen ()

    Return biOK

  Function: fnOpen

   Description: Opens a report file.

   Returns

    Boolean:

   Parameters

   Static Variables

   Local variables

    Number: nNbSection

    Number: nSectionCode

    Number: nNbSubReport

    Number: nIndex

    Number: nIndex2

    String: stName

    Number: nNLinks

    Number: nIsOnDemand

    Number: nExternal

    Number: nReImportOption

    ! Number: bLinkChanged

    ! Number: bReimport

   Actions

    If biOK

     Set biOK = PEOpenEngine(  )

     Set
...

read more »



Mon, 08 Dec 2003 22:47:59 GMT  
 URGENT : CRPE32 (CR8), Subreport And Changing Server (with SQL Server 7.0)
Hi this is the code you will need, hope this helps others
Dim CRApp As New CRAXDRT.Application
Dim crRep As New CRAXDRT.Report

Dim crxtables As DatabaseTables
Dim crxtable As DatabaseTable

Private Sub cmdPrint_Click()
   CommonDialog1.ShowPrinter

   crRep.PrintOut False
End Sub

Private Sub Form_Load()
    Dim crSecs As CRAXDRT.Sections
    Dim crSec As CRAXDRT.Section
    Dim crRepObjs As CRAXDRT.ReportObjects
    Dim crSubRepObj As CRAXDRT.SubreportObject
    Dim crSubReport As CRAXDRT.Report
    Dim ssubreportname As String

    Dim i As Integer
'
    Screen.MousePointer = vbHourglass
    Set crRep = CRApp.OpenReport(sreportname)

    Set crxtables = crRep.Database.Tables

'
'
    If bsage = False Then
        For i = 1 To crxtables.Count

        Set crxtable = crxtables.Item(i)
        crxtable.SetLogOnInfo sDataBase, "", "", ""

        crxtable.SetTableLocation sDataBase, "", ""

        Next i

    Else
        i = 0
      For i = 1 To crxtables.Count

     Set crxtable = crxtables.Item(i)

     If crxtable.Name = "SALES_LEDGER" Or crxtable.Name = "PURCHASE_LEDGER"
Then
        crxtable.SetLogOnInfo sDSN, "Sovreign", sUser, sPassword

     Else
        crxtable.SetLogOnInfo sDataBase, "", "", ""
        crxtable.SetTableLocation sDataBase, "", ""
     End If
    Next i
        crxtable.SetLogOnInfo sDSN, "", sUser, sPassword
    End If
    'log on to subreports

    Set crSecs = crRep.Sections
    For i = 1 To crSecs.Count
      Set crSec = crSecs.Item(i)
      Set crRepObjs = crSec.ReportObjects
        For x = 1 To crRepObjs.Count
          If crRepObjs.Item(x).Kind = crSubreportObject Then

             Set crSubReport =
crRep.OpenSubreport(crRepObjs.Item(x).SubreportName)
             crSubReport.Database.Tables(1).SetLogOnInfo sDataBase, "", "",
""
             crSubReport.Database.Tables(1).SetTableLocation sDataBase, "",
""
          End If
        Next
    Next

'
    If sSQLReportSelection <> "" Then
        crRep.RecordSelectionFormula = sSQLReportSelection
    End If
    If ireportoption = 1 Then
        crRep.FormulaFields.Item(1).Text = "'" & sdatefrom1 & "'"
        crRep.FormulaFields.Item(2).Text = "'" & stodate1 & "'"
    End If
    CRViewer1.EnableExportButton = True

    CRViewer1.EnableProgressControl = True
    CRViewer1.DisplayGroupTree = False
    CRViewer1.EnableDrillDown = False
    CRViewer1.ReportSource = crRep

    CRViewer1.ViewReport
    Screen.MousePointer = vbDefault
   ' bsage = False

End Sub

Private Sub Form_Resize()
    CRViewer1.Top = 0
    CRViewer1.Left = 0
    CRViewer1.Height = ScaleHeight
    CRViewer1.Width = ScaleWidth
End Sub

Malcolm

Quote:
> Hello,

> I would like to know how to change the server of the Database defined in a
> Report Which contains SubReports.

> I have used PESetNthTableLogOnInfo on the primary report and on all the
> subreport that can exist but an error "599- Cannot find the server SQL."
> always appears when i used Report with Subreport.

> If someone have an idea to solve this problem, i listen him

> Thanks in advance

> Woodstock



Fri, 12 Dec 2003 23:39:10 GMT  
 URGENT : CRPE32 (CR8), Subreport And Changing Server (with SQL Server 7.0)
Can You please help me and tell how to Pass Parameters to Report when using
Crystal Report Engine ?

till now I use crystl32.ocx and pass parameters to the report through
following command

CrystalReport1.Parameters(0)="pName;pValue;True"


Quote:
> Hi this is the code you will need, hope this helps others
> Dim CRApp As New CRAXDRT.Application
> Dim crRep As New CRAXDRT.Report

> Dim crxtables As DatabaseTables
> Dim crxtable As DatabaseTable



Sat, 13 Dec 2003 13:35:07 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. CR8 Report Connection/SQL Server 7.0

2. changing Server Name with SQL Server(Urgent)

3. VB6.0 and SQL Server 7.0 OLAP Active X components -URGENT RESPONSE NEEDED

4. New Transact-SQL Debugger for Microsoft SQL Server 6.5/7.0

5. Insert date type varible through ODBC SQL server driver to SQL 7.0 database

6. Problem on SQL-Update Statement with a Data-Control in VB 5 and SQL Server 7.0

7. SQL Debugger for Microsoft SQL Server 7.0 and 6.5

8. SQL-syntax SQL-Server 7.0 / Access 97

9. how do I change Database server in CR8

10. know anything about Stored Proc and using SQL Server 2000, CR8.5 and VB6.0

11. CR8+VB6+SQL Server 2000 and Windows 2000

12. Launch CR8 report against SQL Server or MSDE on W98

 

 
Powered by phpBB® Forum Software