Question

ASP - Crystal Reports in ActiveX viewer

Asked by: jay-are

I have some code that uses the activeX viewer to show crystal reports.  When you try to refresh the report it asks for the sql db username and password of course.  How can I code this with each asp page so it doesn't ask the user for it?  Security isn't an issue here so I just want to make it as easy as possible for the users to view the reports.  Hopefully this is something that can be done in the code.  I'll include it here:

<%@ Language=VBScript%>
<html>
<head>
<title>
Crystal Reports Viewer
</title>
</head>

<OBJECT ID="CRViewer"
CLASSID="CLSID:2DEF4530-8CE6-41C9-84B6-A54536C90213"
WIDTH=100% HEIGHT=100% CODEBASE="activexviewer.cab#Version=9,2,0,442" >
<PARAM NAME="EnableDrillDown" VALUE=1>
<PARAM NAME="EnableExportButton" VALUE=1>
<PARAM NAME="DisplayGroupTree" VALUE=0>
<PARAM NAME="EnableGroupTree" VALUE=0>
<PARAM NAME="EnableAnimationControl" VALUE=1>
<PARAM NAME="EnablePrintButton" VALUE=1>
<PARAM NAME="EnableRefreshButton" VALUE=1>
<PARAM NAME="EnableSearchControl" VALUE=1>
<PARAM NAME="EnableZoomControl" VALUE=1>
<PARAM NAME="EnableSelectExpertButton" VALUE=1>
</OBJECT>

<SCRIPT LANGUAGE="VBScript">
<!--
Sub window_onLoad()
Page_Initialize()
End Sub

Sub Page_Initialize
On Error Resume Next
Dim webBroker
Set webBroker = CreateObject("WebReportBroker9.WebReportBroker")
if err.number <> 0 then
window.alert err.description
window.alert "_LOC_The Crystal ActiveX Viewer is unable to create its resource objects_ENDLOC_."
else
Dim webSource0
Set webSource0 = CreateObject("WebReportSource9.WebReportSource")
webSource0.ReportSource = webBroker
webSource0.URL = "mistakes new detail2.rpt"
webSource0.PromptOnRefresh = True
CRViewer.ReportSource = webSource0
end if

CRViewer.ViewReport
End Sub

-->

</SCRIPT>
</html>

I've tried adding something like mistakes new detail2.rpt?init=activexl;username=blah blah

All that gave me was a blank window.  Help!


This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2003-11-20 at 11:27:36ID20804318
Tags

crystal

,

viewer

,

activex

,

report

,

asp

Topic

Active Server Pages (ASP)

Participating Experts
2
Points
250
Comments
17

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. CLSID of activeX Control
    How Can I find an activeX control's CLSID? (I am using NT4.0, Microsoft VB5.0, VC5.0, and Internet Explorer4.0.) If some specific tool must be used, where can I Download it free?
  2. object classid="clsid:
    i'm looking at some html calling a flash movie: <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.ca b#version=4,0,2,0" width="626" height="200 <para...
  3. ActiveX Crystal Reports
    What is the name of the ActiveX Crystal Report control that I can use in a program like Access? I want to be able to pass parameters to a Crystal Report, and have the report print out. I have a crystal viewer control, but I can't seem to to get it to work right/don't know h...
  4. Unable to load a crystal report using activex
    The following code opens a blank crystal report object in the browser while I want it to load the report "Report1.rpt". The report as well as the source code are in the dir /testing. I am using Win XP. <html> <body language="VBScript" onload=&qu...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: fritz_the_blankPosted on 2003-11-20 at 12:44:13ID: 9790425

Does this make a difference?

webSource0.PromptOnRefresh = True


What if that is set to false?

FtB

 

by: jay-arePosted on 2003-11-20 at 12:53:49ID: 9790498

When I load up the page it shows the report and everything fine.  It only asks for the db logon and pass when you hit refresh.  With that set to false it asks for it as soon as you load up the viewer.

 

by: fritz_the_blankPosted on 2003-11-20 at 13:16:39ID: 9790667

Oh, that's even worse!

Once again, let apologize for my ignorance about the .net environment before I start...

What would happen if you set up and opened your connection object for the report explicitly first? That way, you shouldn't be prompted...


FtB

 

by: jay-arePosted on 2003-11-20 at 13:21:41ID: 9790722

I'm not sure.  This is a classic asp page so I'm even further lost than if it was asp.net!  :)

I *borrowed* this code from someone else on EE that was doing the same thing I was.  

 

by: fritz_the_blankPosted on 2003-11-20 at 13:32:37ID: 9790817

 

by: jay-arePosted on 2003-11-20 at 13:56:36ID: 9790982

FtB:

I've looked over their docs before and haven't had much luck.  I did find this in there:

 With crConnectionInfo
            .ServerName = "EnterServerNameHere"
            .DatabaseName = "Pubs"
            .UserID = "EnterUserIDHere"
            .Password = "EnterPasswordHere"
        End With

So I changed my code:
ebSource0.ServerName = "Gwpf-web01"
webSource0.DatabaseName = "Gwpf"
webSource0.UserID = "userid"
webSource0.Password = "pass"

So I did that but when I hit refresh on the viewer its still asking for the username and pass.  This particular set of reports is also pulling data from 2 tables in 2 different databases.  I'll spend some more time looking through these samples!!

 

by: fritz_the_blankPosted on 2003-11-20 at 14:00:58ID: 9791015

I thought that you ended up consolodating your DB's or am I thinking about someone else?

In any case, if you can work with one the simple examples there, that would be best. The code that you posted above is IE only and relies a fair deal on client-side scripting. I would prefer to do as much of this server side as possible.

FtB

 

by: jay-arePosted on 2003-11-20 at 14:05:38ID: 9791045

Yeah I did consolidate db's but these reports haven't been rebuilt yet and are for testing purposes for now.  I will go back later and change them to the one db when they go live on the website.

I guess I need to scrap this borrowed asp page and use one of crystal's sample asp.net pages since I'm a little more familiar with it.  I will continue reading up on this tonight and tomorrow morning and let you know what I find out.
Thanks!

 

by: fritz_the_blankPosted on 2003-11-20 at 14:21:53ID: 9791150

I know that it is a pain, but since you are working in .net already, it might be best to learn how to use CR in that environment so that you don't have to switch back and forth. Once you get one report working (and make it a very simple test report--maybe something that just displays today's date) the rest should be easier.

FtB

 

by: mlmccPosted on 2003-11-25 at 20:30:37ID: 9822465

I don't know how well CR handles report names with blanks.

You might try renaming the report
webSource0.URL = "mistakes_new_detail2.rpt"

mlmcc

 

by: jay-arePosted on 2003-11-26 at 06:17:56ID: 9824689

Actually I haven't had any problems with the report names.  I just can't figure out how to embed the database logon info in the asp code.  I've found some examples at crystal decisions but they all seem to be visual basic programs.  I don't have that program so that didn't help much.  

My boss may buy it for me as an xmas gift so we shall see.  Otherwise if you have any ideas on adding the UID & PWD to the code that would help!  :)

 

by: mlmccPosted on 2003-11-26 at 19:19:34ID: 9829326

I use VB and we are using NT integrated security on the database so I don't have to pass the username and password.

This might help

http://support.crystaldecisions.com/communityCS/FilesAndUpdates/aspxmps8.exe.asp

If not which version and edition of Crystal?

mlmcc

 

by: jay-arePosted on 2003-12-01 at 12:04:52ID: 9852567

We are using CR9 with the enterprise pack.  So the logons are set to Enterprise instead of NT.  I don't think that's something I can change easily.


I've found all sorts of examples but haven't had much luck so far.  Keep in mind I'm a noob to VB and Crystal.

I have an asp page that does work but it uses the DHTML viewer.  It logs onto the enterprise server first I guess and find the published report and displays it.  I've been trying to adapt it for the activex viewer with no luck.

here is the code:
<%
            dim SessionManager, Sess
            Set SessionManager = Server.CreateObject("CrystalEnterprise.SessionMgr")
            Set Sess = SessionManager.Logon("administrator", "", "myserver", "secEnterprise")


    ' Get the current info store object.
    Dim iStore, id, result
    Set iStore = Sess.Service ("", "InfoStore")

      Function DisplayReport(strReportName)

            Set result = iStore.Query("Select SI_ID, SI_NAME From CI_INFOOBJECTS Where SI_NAME = 'New' And SI_INSTANCE = 0")

    ' Get the ID of the report to be viewed.
    id = result.Item(1).ID

    ' Create the viewer and its report source.
    Dim viewer1, rptFactory, rptSource
    Set viewer1 = Server.CreateObject( "CrystalReports.CrystalReportViewer" )
    Set rptFactory = iStore.EnterpriseSession.Service("", "PSReportFactory")
    Set rptSource = rptFactory.OpenReportSource(CInt(id))

    ' Set the viewer's properties to prepare it for viewing.
    With viewer1
                        .HasCrystalLogo = False
                        .IsDisplayGroupTree = False
                        .IsEnableDrillDown = True

        .ReportSource = rptSource
        .EnterpriseLogon = iStore.EnterpriseSession
          .Refresh
        .HasRefreshButton = True

    End With

    If Err.Number <> 0 Then
    'There was an error setting up the viewer.
        Response.Write "Unable to create report viewer. " & Err.description
    Else
    'Process the request and launch the viewer.
        viewer1.ProcessHttpRequest Request, Response, Session
    End If

End Function

%>

Any ideas?  I finally got a copy of Visual Studio.Net so I've been trying to work with it but it will take me some time to learn how to do everything with it...

 

by: jay-arePosted on 2003-12-02 at 14:16:36ID: 9862131

I've solved it!  Actually someone else helped me but its working.

The solution:

webSource0.URL = "mistakes new detail3.rpt?user0=sa&password0=bigdellsql1&user1=sa&password1=bigdellsql1&user2=sa&password2=bigdellsql1"

When using the RDC you have to just pass the username and pass with the url.
I tried this once but didn't have the syntax right so I moved onto something else.
I'm going to split the points since both of you gave me links to stuff that helped!

Thanks!

 

by: fritz_the_blankPosted on 2003-12-02 at 14:47:42ID: 9862413

I am sorry not to have helped any more--it seems that all of the questions that you have been asking of late have fallen outside my area of experience.

I am glad that you are set.

Fritz the Blank

 

by: jay-arePosted on 2003-12-02 at 14:49:25ID: 9862429

Actually the examples you pointed me towards helped out.  I just had to sit down with a Crystal Enterprise guy and talk about the examples and why it wouldn't work and bam we got it to work.

Thank God, cause the plain HTML viewer that I was using is nasty!

Thanks for your help and I'm sure I'll have more questions soon!

 

by: mlmccPosted on 2003-12-02 at 18:25:26ID: 9863602

Glad I could help

mlmcc

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...