Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL database login?

Status
Not open for further replies.

redsand23

Technical User
Feb 22, 2002
77
US
I have the below asp page that uses crystals canned web pages to view reports. When I run the report it asks me to login to sql. Is there a way to put that login&password info into the asp page and then set .EnableLogonPrompt = false

<%@ Language=VBScript%>
<%
Response.ExpiresAbsolute = Now() - 1
Session.CodePage = 65001 ' UTF-8

Dim objFactory 'Use the ObjectFactory object to abstract the version number to one location
Set objFactory = CreateObject("CrystalReports.ObjectFactory.2")

Const REPORTSOURCEPARAM = "C:\Program Files\Crystal Decisions\Report Application Server 9\Reports\VendorRatingMain.rpt"
Const CRREPORTSOURCE = "CrystalReportReportSource"

Sub OutputReport()
' DESCRIPTION : Use the web report viewer to view the report specified by the "reportsource"
' request parameter
Dim reportSource
Dim viewer

Dim requestMethod
requestMethod = UCase(Request.ServerVariables("REQUEST_METHOD"))

Select Case requestMethod
Case "POST"
reportSource = Request.Form(REPORTSOURCEPARAM)
Case "GET"
reportSource = Request.QueryString(REPORTSOURCEPARAM)
Case Else
reportSource = Empty
End Select

' View report
If (IsEmpty(reportSource)) Then
reportSource = Session(CRREPORTSOURCE)
End If

If Not (IsEmpty(reportSource)) Then
Session(CRREPORTSOURCE) = reportSource

Set viewer = objFactory.CreateObject("CrystalReports.CrystalReportViewer")


viewer.ReportSource = ReportSource

With viewer


.isdisplaygrouptree=false
'.EnableLogonPrompt = false
.ReportSource = reportSource
.IsOwnPage = false
.HasRefreshButton = true
.Name = "HTML Page Viewer"
End With

Call viewer.ProcessHttpRequest(Request, Response, Session)
End If

if Err.number <> 0 then
Response.Write Err.Description
Err.Clear
end if

Set viewer = nothing
End Sub

%>
 
Here is an example of Setlogon

' WORKING WITH SETLOGONINFO
'
' The datasource here is called "Pubs Sample Database". It is a System
' Datasource (DSN), and points to the "pubs" database, which is installed
' with SQL Server. You will also need to change your user id and
' password.

'Create a reference to the tables collection of the main report
Set mainReportTableCollection = Session("oRpt").Database.Tables


For Each mnTable in mainReportTableCollection
With mnTable.ConnectionProperties
.Item("user ID") = "user"
.Item("Password") = "password"
.Item("DSN") = "Pubs Sample Database"
.Item("Database") ="pubs"
End With
Next

Hope this helps
 
JaneDane

While this should do the trick for redsand, just thought I'd mention thate the sample code actually illustrates the ConnectionPropery Object rather than SetLogOnInfo.

SetLogOnInfo is the old method used by CR which has been deprecated since V9.





Gary Parker
Systems Support Analyst
Manchester, England
 
Thanks for the example. I put that code in the above asp page and this is what I got

Invalid character
/kpi/procurement/test/ViewReport/reportPageViewer.asp, line 15, column 45
For Each mnTable in mainReportTableCollection

When I add this code to the asp page, do I still need to setup the odbc connection inside of the report?

Again, I am obviously new to this and appreciate any help!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top