Results 1 to 4 of 4

Thread: Crystal reports and ADO

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 1999
    Location
    Linköping, Sweden
    Posts
    19
    I have data in an ADO-recordset in VB6 EE. I want to create a report with data from that recordset using Crystal Reports shipped with VB6 EE (version 4.6).
    I can't get it right! Does Crystal Reports only support DAO?

    Can I perhaps create a report file with Crystal Reports 4.6 and then use the run time library for Crystal Reports 8 that were shipped with VB?

    What can I do?
    /Magnus

  2. #2
    Lively Member
    Join Date
    Jun 2000
    Posts
    80

    Thumbs up

    Crystal Reports version 8 will work with ADO.

    (Later on in our project we will use it, so I have already checked the possibility, we will start programming the reports in a few weeks, so this is all I know about CR & VB at this moment, sorry)

    good luck,

    Fedor

  3. #3
    Member MaBen's Avatar
    Join Date
    Apr 2000
    Location
    Sherbrooke, Québec, Canada
    Posts
    38

    Smile CR 6.0 and ADO

    I'm using Crystal Report 6.0 with ADO 2.5 and it's working perfectly.

    I'm using the Crystal Report Designer, witch is call by the project menu in VB. In CR Designer you can set up the database connection and the SQL statement. And in VB you can force your report to use your RecordSet like this:

    Form module declaration
    Code:
    Public myReport As New dsrmyReport
    dsrmyReport is my report created by CR Designer


    Sub that preview my report with my RecordSet
    Code:
      Dim NewPreview As New frmPreview
        
      Dim cnnDossier As ADODB.Connection
      Dim cmdDossier As ADODB.Command
      Dim rsHeuresB As ADODB.Recordset
    
      On Error GoTo ErrorHandler
      
        Set cnnDossier = New ADODB.Connection
        
        With cnnDossier
          .CursorLocation = adUseClient
          .Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Dossiers;Data Source=Serveur"
        End With
        
        Set cmdDossier = New ADODB.Command
        Set rsHeuresB = New ADODB.Recordset
        
        ' Using stored procedure with parameter on SQL server 7.0
        With cmdDossier
          Set .ActiveConnection = cnnDossier
          .CommandText = "sproc_compHeuresB_Semaine_User"
          .CommandType = adCmdStoredProc
          .Parameters("@Semaine") = nMySemaine
          .Parameters("@Annee") = nMyAnnee
        End With
        
        'Création du Recordset
        rsHeuresB.Open cmdDossier, , adOpenDynamic, adLockReadOnly
        
        
        With myReport 
          .Database.SetDataSource rsHeuresB
          .Database.Verify
        
          NewPreview.CRViewer1.ReportSource = myReport 
        End With
        
        NewPreview.CRViewer1.ViewReport
        NewPreview.Show
      
          
        rsHeuresB.Close
        cnnDossier.Close
        
        
        Set rsHeuresB = Nothing
        Set cmdDossier = Nothing
        Set cnnDossier = Nothing
        
      End If
      
      On Error GoTo 0
      
      
      Exit Sub
    ErrorHandler:
        Select Case Err.Number
           ...
    Have fun...

  4. #4
    Lively Member
    Join Date
    Jul 2000
    Location
    Brunei
    Posts
    100

    Re: CR 6.0 and ADO

    Originally posted by MaBen
    I'm using Crystal Report 6.0 with ADO 2.5 and it's working perfectly.

    I'm using the Crystal Report Designer, witch is call by the project menu in VB. In CR Designer you can set up the database connection and the SQL statement. And in VB you can force your report to use your RecordSet like this:

    Form module declaration
    Code:
    Public myReport As New dsrmyReport
    dsrmyReport is my report created by CR Designer


    Sub that preview my report with my RecordSet
    Code:
      Dim NewPreview As New frmPreview
        
      Dim cnnDossier As ADODB.Connection
      Dim cmdDossier As ADODB.Command
      Dim rsHeuresB As ADODB.Recordset
    
      On Error GoTo ErrorHandler
      
        Set cnnDossier = New ADODB.Connection
        
        With cnnDossier
          .CursorLocation = adUseClient
          .Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Dossiers;Data Source=Serveur"
        End With
        
        Set cmdDossier = New ADODB.Command
        Set rsHeuresB = New ADODB.Recordset
        
        ' Using stored procedure with parameter on SQL server 7.0
        With cmdDossier
          Set .ActiveConnection = cnnDossier
          .CommandText = "sproc_compHeuresB_Semaine_User"
          .CommandType = adCmdStoredProc
          .Parameters("@Semaine") = nMySemaine
          .Parameters("@Annee") = nMyAnnee
        End With
        
        'Création du Recordset
        rsHeuresB.Open cmdDossier, , adOpenDynamic, adLockReadOnly
        
        
        With myReport 
          .Database.SetDataSource rsHeuresB
          .Database.Verify
        
          NewPreview.CRViewer1.ReportSource = myReport 
        End With
        
        NewPreview.CRViewer1.ViewReport
        NewPreview.Show
      
          
        rsHeuresB.Close
        cnnDossier.Close
        
        
        Set rsHeuresB = Nothing
        Set cmdDossier = Nothing
        Set cnnDossier = Nothing
        
      End If
      
      On Error GoTo 0
      
      
      Exit Sub
    ErrorHandler:
        Select Case Err.Number
           ...
    Have fun...
    Hi,

    Thanks for posting the above code.

    To use this statement,

    Public MyReport as New dsrMyreport,

    What are the refereneces and components, I have to add to my
    report? I use SCR 8.0 version and VB 6.0.

    Thanks for your support.

    sincerely,
    Rathi

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width