Solved

ASP - Crystal Reports in ActiveX viewer

Posted on 2003-11-20
17
4,123 Views
Last Modified: 2007-12-19
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!


0
Comment
Question by:jay-are
  • 8
  • 6
  • 3
17 Comments
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9790425
Does this make a difference?

webSource0.PromptOnRefresh = True


What if that is set to false?

FtB
0
 

Author Comment

by:jay-are
ID: 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.
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 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
0
 

Author Comment

by:jay-are
ID: 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.  

0
 
LVL 46

Assisted Solution

by:fritz_the_blank
fritz_the_blank earned 125 total points
ID: 9790817
0
 

Author Comment

by:jay-are
ID: 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!!
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 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
0
 

Author Comment

by:jay-are
ID: 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!
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 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
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 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
0
 

Author Comment

by:jay-are
ID: 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!  :)

0
 
LVL 100

Accepted Solution

by:
mlmcc earned 125 total points
ID: 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
0
 

Author Comment

by:jay-are
ID: 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...
0
 

Author Comment

by:jay-are
ID: 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!
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 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
0
 

Author Comment

by:jay-are
ID: 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!
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 9863602
Glad I could help

mlmcc
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now