CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: Error

  1. #1
    Join Date
    Jun 2002
    Location
    Kuwait
    Posts
    44

    Question Error

    Hello,

    Following is the code written to call a crystal report having records for branch 3 only:

    Dim appl As New CRAXDRT.Application
    Dim rpt As New CRAXDRT.Report
    Dim dat As CRAXDRT.Database

    Dim cn As ADODB.Connection
    Dim rs As ADODB.Recordset

    Set rpt = appl.OpenReport(app.path & "\password.rpt", 1)

    Set cn = New ADODB.Connection
    Set rs = New ADODB.Recordset
    cn.Open "dsn=invdet"
    rs.Open "select * from table1 where branch=3", cn, adOpenStatic, adLockPessimistic

    Set dat = rpt.Database
    dat.SetDataSource rs, 3, 1
    CR.ReportSource = rpt
    CR.ViewReport

    Error:

    The Report shows all the records from "table1". It resembles the same report when I run from Crystal Reports.

    i.e. it is not reporting for the above recordset set.

  2. #2
    Join Date
    Jul 2003
    Location
    Florida
    Posts
    651
    My changes are in Bold.

    Code:
    'Get rid of these
    'Dim appl As New CRAXDRT.Application
    'Dim rpt As New CRAXDRT.Report
    'Dim dat As CRAXDRT.Database
    
    Dim Report as CrystalReport1 'This is the dsr file that you create
    
    Dim cn As ADODB.Connection
    Dim rs As ADODB.Recordset
    
    Set rpt = appl.OpenReport(app.path & "\password.rpt", 1)
    
    Set cn = New ADODB.Connection
    Set rs = New ADODB.Recordset
    cn.Open "dsn=invdet"
    rs.Open "select * from table1 where branch=3", cn, adOpenStatic, adLockPessimistic
    
    Report.SetDataSource rs, 3, 1
    'Make sure CR is the name of the CrystalViewer on your form
    CR.ReportSource = Report
    CR.ViewReport
    I'd rather be wakeboarding...

  3. #3
    Join Date
    Jun 2002
    Location
    Kuwait
    Posts
    44
    I do not know how to create the dsr file

  4. #4
    Join Date
    Jul 2003
    Location
    Florida
    Posts
    651
    What version of Crystal Reports are you using?
    I'd rather be wakeboarding...

  5. #5
    Join Date
    Jun 2002
    Location
    Kuwait
    Posts
    44
    I am using version 8.5

  6. #6
    Join Date
    Jul 2003
    Location
    Florida
    Posts
    651
    I'm using version 8.5 Developer Edition. When I installed it, it placed all the necessary dlls on my comuter for me.

    To create a dsr file, All I have to do is click 'Project', 'Add Crystal Reports 8.5'. Then follow the directions to create a dsr file.
    I'd rather be wakeboarding...

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

Featured