Results 1 to 2 of 2

Thread: Problem with data selection in Crystal Report (Very Very Urgent)

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2002
    Posts
    94

    Problem with data selection in Crystal Report (Very Very Urgent)

    Hi Friends,

    I've used following code to display report

    VB Code:
    1. Dim rs As New ADODB.Recordset
    2.     Dim crystal As CRAXDDRT.Application
    3.     Dim Report As CRAXDDRT.Report
    4.     'CRViewer1.DisplayBorder = False
    5.     'CRViewer1.DisplayTabs = False
    6.     CRViewer1.EnableDrillDown = False
    7.     Set crystal = New CRAXDDRT.Application
    8.     Set Report = crystal.OpenReport("d:\damini\school\reports\BankLetter.rpt")
    9.     'Report.fo
    10. '    Report.FormulaFields(0) = "Mr. XXX"
    11.     rs.CursorLocation = adUseClient
    12.     rs.Open "select * from tblStudent where studentid='S15'", cn
    13.     Report.DiscardSavedData
    14.     Report.EnableParameterPrompting = False
    15.     Report.ParameterFields(1).AddCurrentValue "Mr. XXX"
    16.     Report.Database.SetDataSource rs
    17. '    Report.foru
    18.     CRViewer1.ReportSource = Report
    19.     CRViewer1.ViewReport
    20.     Do While CRViewer1.IsBusy
    21.         DoEvents
    22.     Loop
    23.     CRViewer1.Zoom 100

    But instead of showing report of only that student whose id is S15, it is showing for all the records in the table. plz help me how to solve it. Early help is appreciated

    plz reply soon
    Last edited by damini_dd; Mar 22nd, 2006 at 10:53 AM.

  2. #2
    Member
    Join Date
    Aug 2004
    Location
    Northern Territory, Australia
    Posts
    61

    Re: Problem with data selection in Crystal Report (Very Very Urgent)

    I think the problem is with the sql - grammar and syntax are ALL important, and not easy to troubleshoot.

    It looks from your code example that the last few characters of your sql command:

    rs.Open "select * from tblStudent where studentid='S15'", cn

    have been commented out - after the last single quote - VB has read that last single quote as a comment starter.

    Try putting gaps between the equal sign and the single quotes, thus:

    rs.Open "select * from tblStudent where studentid = 'S15' ", cn

    If that doesn't help ... why are you coding a specific value in a sql string anyway? Surely it would be more useful to pass a field name or some other parameter?

    good luck, Peter

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