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

Thread: CR viewer

  1. #1
    Join Date
    Oct 2009
    Posts
    4

    CR viewer

    I am a VB6 Programmer, Iam tyring to view a .rpt file using the CRViewer control in VB. The Report is not showing in the CR Viewer control , it gives a message Server has not yet been opened. but it is displaying when I use Access database.
    I am using a SQL Server 2000 database. Could u please tell me how to connect the database to the crviewer.. Iam pasting the source code below..Kindly help.

    Set cReport = appn.OpenReport(App.Path + "\reports\rptsearch.rpt")
    cReport.Database.LogOnServer "pdsodbc.dll", "humaida", ldvahan, sa, sa

    cReport.DiscardSavedData
    CRViewer1.ReportSource = cReport
    cReport.PaperSize = crPaperA4
    CRViewer1.ViewReport

  2. #2
    Join Date
    Sep 2006
    Posts
    635

    Re: CR viewer

    Quote Originally Posted by lakuser View Post
    I am a VB6 Programmer, Iam tyring to view a .rpt file using the CRViewer control in VB. The Report is not showing in the CR Viewer control , it gives a message Server has not yet been opened. but it is displaying when I use Access database.
    I am using a SQL Server 2000 database. Could u please tell me how to connect the database to the crviewer.. Iam pasting the source code below..Kindly help.

    Set cReport = appn.OpenReport(App.Path + "\reports\rptsearch.rpt")
    cReport.Database.LogOnServer "pdsodbc.dll", "humaida", ldvahan, sa, sa

    cReport.DiscardSavedData
    CRViewer1.ReportSource = cReport
    cReport.PaperSize = crPaperA4
    CRViewer1.ViewReport
    for your code, you have to seeting a
    ODBC called "humaida"
    databases "ldvahan"
    user id "sa"
    password "sa"

    Code:
    DIM ldvahan as String
    dim UserId as string ''login onto SQL Server DataBase 
    dim PWd as string  ''password
    
    ldvahan="namedatabase"
    userid="mylogin"
    PWD="password"
    
    cReport.Database.LogOnServer "pdsodbc.dll", "humaida", ldvahan, sa, sa

  3. #3
    Join Date
    Oct 2009
    Posts
    4

    Re: CR viewer

    thanks .......

    it is working

  4. #4
    Join Date
    Oct 2009
    Posts
    4

    Re: CR viewer

    I want to pass parameter from form to reports. how to pass this parameter in CRVIEWER....
    please help me thanks in advance

  5. #5
    Join Date
    Nov 2004
    Location
    LA. California Raiders #1 AKA: Gangsta Yoda™
    Posts
    616

    Re: CR viewer

    If you have created the parameters in your CR already then just use in your VB6 code the Parameters collection to specify and set their values.

    Code:
    oReport.ParameterFields.Items(1).ClearCurrentValueAndRange
    oReport.ParameterFields.Items(1).Add strValue1
    oReport.ParameterFields.Items(2).ClearCurrentValueAndRange
    oReport.ParameterFields.Items(2).Add strValue2
    VB/Office Guru™ (AKA: Gangsta Yoda™)
    VB Forums - Super Moderator 2001-Present

    Microsoft MVP 2006-2011

    Please use [code]your code goes in here[/code] tags when posting code.

    Senior Software Engineer MCP, BSEE, CET
    VS 2012 Premium, VS 6.0 Enterprise SP6, VSTO, Office Ultimate 2010, Windows 7 Ultimate
    Star Wars Gangsta Rap SE Reputations & Rating Posts Office Primary Interop AssembliesAdvanced VB/Office Guru™ Word SpellChecker™.NETAdvanced VB/Office Guru™ Word SpellChecker™ VB6Outlook Global Address ListVB6/Crystal Report Ex.VB6/CR Print Setup Dialog Ex.

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