abishome
asked on
Crystal Reports 9 Conecting to sql server DSN asking for username and password
When designing the report I used a DSN name that exactly the same as on the server that runs the report server for my website. Everytime I run the report it keeps asking for a username and password. Can I do something in the viewer some code or something to tell it what the username and password are?
the report needs to be logged on at the database unless you are using nt authentication for sql server? Try executing tthe Logon command after instantiating the report object. I am not too familiar with ras asp but this seems to be missing in your extract?
Session("pathReport").Data baseContro ller.Logon "user", "password"
There are more samples in here, with a lot of info on database logon
http://support.crystaldecisions.com/communityCS/TechnicalPapers/apps_ras.pdf
Also make sure that the server has a System DSN, not a User DSN
Session("pathReport").Data
There are more samples in here, with a lot of info on database logon
http://support.crystaldecisions.com/communityCS/TechnicalPapers/apps_ras.pdf
Also make sure that the server has a System DSN, not a User DSN
try it..iam a new to this..but trying to provide based on the thing i infered from u r ques
using
<appSettings>
<add key="ConnectionString" value="Data Source=dsnname;Initial Catalog=;User ID=id;password=password;"/ >
</appSettings>
and call it when req..
using
<appSettings>
<add key="ConnectionString" value="Data Source=dsnname;Initial Catalog=;User ID=id;password=password;"/
</appSettings>
and call it when req..
what does the Session("pathReport") contain? Just the report path as a String, ie "C:\report.rpt" ?
ASKER
There are two files that get called when linking to the report. This is the first
<%
'========================= ========== ========== ========== ========== ========== ========
' Creation Date: July 2003
' Author: ES
' Purpose: This sample ASP application demonstrates how to use the Report Application
' Server (RAS) Viewer SDK to pass values to discrete report parameters.
'========================= ========== ========== ========== ========== ========== ========
'Specify the report to be opened
'reportname = "SimpleParameters.rpt"
reportname = request.QueryString("Repor tName")
'Use this object to create other RAS objects
Set Session("ObjFactory") = CreateObject("CrystalRepor ts.ObjectF actory.2")
'This "While/Wend" loop is used to determine the physical path (eg: C:\) to the
'Crystal Report file by translating the URL virtual path (eg: http://Domain/Dir)
Path = Request.ServerVariables("P ATH_TRANSL ATED")
While (Right(Path, 1) <> "\" And Len(Path) <> 0)
iLen = Len(Path) - 1
Path = Left(Path, iLen)
Wend
'Store the Path and report into a session variable as it will be used by the viewer code
Session("pathReport") = Path & reportname
'The ServerControl object provides us with an interface to a variety of RAS Services
Set oServerControl = Session("ObjFactory").Crea teObject(" CrystalRep orts.Cryst alReportSe rverContro l")
'We need to open the report for modification (in this case passing parameters)
oServerControl.reportSourc e = Session("pathReport")
oServerControl.processHttp Request Request, Response, Null
'Retrieve all the parameters from the report
Set ParamCollection = oServerControl.ParameterFi elds
'This subroutine expects two values, the parameter name and its value
Sub PassParameter(strParamName , ParamValue)
'determine the index value of the parameter in the collection
paramIndex = ParamCollection.Find(strPa ramName, 0)
'add a current value to the parameter
ParamCollection.Item(param Index).Cur rentValues .Add ParamValue
End Sub
'Pass parameters to the report using the PassParameter subroutine
'This will also work for multi-value discreet parameters
'PassParameter "StringParam", CStr("I am a string")
'PassParameter "StringParam", CStr("I am also a string")
'PassParameter "NumberParam", CInt("123")
'PassParameter "CurrencyParam", CDbl("321.123")
'PassParameter "BooleanParam", CBool("True")
'PassParameter "DateParam", CDate("2001/Jan/02")
'PassParameter "TimeParam", CDate("3:45:00 PM")
'PassParameter "DateTimeParam", CDate("2001/Jan/02 3:45:00 PM")
'PassParameter "res_id", 725
For each item in Request.QueryString
'response.write item & "********" & Request.QueryString(item) & "<br>"
if item <> "ReportName" then
response.write item & ": " & CStr(Request.QueryString(i tem)) & "<br>"
PassParameter item, CStr(Request.QueryString(i tem))
end if
next
'Store the modified collection of parameters in session as it is used by the viewer code
Set Session("ParamCollection") = ParamCollection
'Redirect to viewer code
Response.Redirect "CrystalReportViewer.asp"
%>
As you can see this redirects to the Viewer the code for that is
<%@ Language=VBScript %>
<%
'Create the Report Viewer object
'Set HTMLViewer = CreateObject("CrystalRepor ts.Crystal ReportView er")
Set HTMLViewer = Session("ObjFactory").Crea teObject(" CrystalRep orts.Cryst alReportIn teractiveV iewer")
Set rptAppSession = Session("ObjFactory").Crea teObject(" CrystalRep orts.Repor tAppSessio n")
rptAppSession.Initialize
If Err.Number <> 0 Then
Response.Write "Failed to initialize ReportAppSession."
Response.Write "Error message: " & Err.Description
Err.Clear
End If
Set OpenReport = rptAppSession.CreateServic e("Crystal ClientDoc. ReportClie ntDocument ")
'Supply the viewer with information it needs and set any viewer attributes
With HTMLViewer
.ReportSource = Session("pathReport")
.IsOwnPage = True
.IsEnableDrillDown = True
.IsDisplayGroupTree = False
End With
'Check that ParamCollection is not null or empty
If Session("ParamCollection") .Count > 0 Then
HTMLViewer.ParameterFields = Session("ParamCollection")
End If
'Display the report in the viewer
HTMLViewer.ProcessHttpRequ est Request, Response
%>
<%
'=========================
' Creation Date: July 2003
' Author: ES
' Purpose: This sample ASP application demonstrates how to use the Report Application
' Server (RAS) Viewer SDK to pass values to discrete report parameters.
'=========================
'Specify the report to be opened
'reportname = "SimpleParameters.rpt"
reportname = request.QueryString("Repor
'Use this object to create other RAS objects
Set Session("ObjFactory") = CreateObject("CrystalRepor
'This "While/Wend" loop is used to determine the physical path (eg: C:\) to the
'Crystal Report file by translating the URL virtual path (eg: http://Domain/Dir)
Path = Request.ServerVariables("P
While (Right(Path, 1) <> "\" And Len(Path) <> 0)
iLen = Len(Path) - 1
Path = Left(Path, iLen)
Wend
'Store the Path and report into a session variable as it will be used by the viewer code
Session("pathReport") = Path & reportname
'The ServerControl object provides us with an interface to a variety of RAS Services
Set oServerControl = Session("ObjFactory").Crea
'We need to open the report for modification (in this case passing parameters)
oServerControl.reportSourc
oServerControl.processHttp
'Retrieve all the parameters from the report
Set ParamCollection = oServerControl.ParameterFi
'This subroutine expects two values, the parameter name and its value
Sub PassParameter(strParamName
'determine the index value of the parameter in the collection
paramIndex = ParamCollection.Find(strPa
'add a current value to the parameter
ParamCollection.Item(param
End Sub
'Pass parameters to the report using the PassParameter subroutine
'This will also work for multi-value discreet parameters
'PassParameter "StringParam", CStr("I am a string")
'PassParameter "StringParam", CStr("I am also a string")
'PassParameter "NumberParam", CInt("123")
'PassParameter "CurrencyParam", CDbl("321.123")
'PassParameter "BooleanParam", CBool("True")
'PassParameter "DateParam", CDate("2001/Jan/02")
'PassParameter "TimeParam", CDate("3:45:00 PM")
'PassParameter "DateTimeParam", CDate("2001/Jan/02 3:45:00 PM")
'PassParameter "res_id", 725
For each item in Request.QueryString
'response.write item & "********" & Request.QueryString(item) & "<br>"
if item <> "ReportName" then
response.write item & ": " & CStr(Request.QueryString(i
PassParameter item, CStr(Request.QueryString(i
end if
next
'Store the modified collection of parameters in session as it is used by the viewer code
Set Session("ParamCollection")
'Redirect to viewer code
Response.Redirect "CrystalReportViewer.asp"
%>
As you can see this redirects to the Viewer the code for that is
<%@ Language=VBScript %>
<%
'Create the Report Viewer object
'Set HTMLViewer = CreateObject("CrystalRepor
Set HTMLViewer = Session("ObjFactory").Crea
Set rptAppSession = Session("ObjFactory").Crea
rptAppSession.Initialize
If Err.Number <> 0 Then
Response.Write "Failed to initialize ReportAppSession."
Response.Write "Error message: " & Err.Description
Err.Clear
End If
Set OpenReport = rptAppSession.CreateServic
'Supply the viewer with information it needs and set any viewer attributes
With HTMLViewer
.ReportSource = Session("pathReport")
.IsOwnPage = True
.IsEnableDrillDown = True
.IsDisplayGroupTree = False
End With
'Check that ParamCollection is not null or empty
If Session("ParamCollection")
HTMLViewer.ParameterFields
End If
'Display the report in the viewer
HTMLViewer.ProcessHttpRequ
%>
ASKER
vairavamuthu,
I don't understand what you are refering to
I don't understand what you are refering to
why not set user/password in Crystal Enterprise 9's management Console!
ASKER
here is the pop up I am getting. The only software I have running on the server is RAS My users are getting anoyed and I don't know what to do
The report you requested requires further information.
-------------------------- ---------- ---------- ---------- ---------- ---------- ----
Database Logon
Server Description dbName
Database Type ODBC (RDO)
User Id
Password
The report you requested requires further information.
--------------------------
Database Logon
Server Description dbName
Database Type ODBC (RDO)
User Id
Password
this should solve it, i take you are using the eportfolio lite
http://support.businessobjects.com/library/kbase/articles/c2013600.asp
http://support.businessobjects.com/library/kbase/articles/c2013600.asp
ASKER
I am not using eportfolio light. I am just using the viewers from an asp page. The entire code for my asp pages is includeded above. According to your documentation link it says to change a specific line in my code. My code does not contain that line.
ASKER
I got the latest sample files from Crystal and everything was resolved using these updated files.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
<%@ Language=VBScript %>
<%
'Create the Report Viewer object
'Set HTMLViewer = CreateObject("CrystalRepor
Set HTMLViewer = Session("ObjFactory").Crea
Set rptAppSession = Session("ObjFactory").Crea
rptAppSession.Initialize
If Err.Number <> 0 Then
Response.Write "Failed to initialize ReportAppSession."
Response.Write "Error message: " & Err.Description
Err.Clear
End If
Set OpenReport = rptAppSession.CreateServic
'Supply the viewer with information it needs and set any viewer attributes
With HTMLViewer
.ReportSource = Session("pathReport")
.IsOwnPage = True
.IsEnableDrillDown = True
.IsDisplayGroupTree = False
End With
'Check that ParamCollection is not null or empty
If Session("ParamCollection")
HTMLViewer.ParameterFields
End If
'Display the report in the viewer
HTMLViewer.ProcessHttpRequ
%>