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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Storing the ODBC Password when using RAS CE9

Status
Not open for further replies.

sbdavis

Programmer
Feb 12, 2003
18
US
RAS CE9 no longer provides password storage, like CE8 does. To avoid the prompt for username and password when running a report, just store the password in the ODBC registry entry using the string name "Password". Note that this works for CR9 also.
 
Can you detail exactly how you add this to the ODBC registry with syntax and location?
 
1) From a DOS prompt, run the program REGEDIT.

2) Go to the registry entry [HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI]

3) You will see a list of your ODBC data sources.

4) Right-click on the desired ODBC data source. Choose New -> String Value.

5) Enter "Password" for the new string name and press the Enter key.

6) Double-click on the new string name, which will bring up a dialog box.

7) Enter the ODBC password as the string value. Click OK.

8) If you make a mistake, you can right-click on the new string value and choose Delete, Rename, Modify, etc.

9) Test using CR9 and RAS9.
 
I no longer have CE8 and CR8.5 installed, but I would guess that these versions also try to read the ODBC password from the registry (like reading the ODBC username), then prompt if the password is not found.
 
I've tried this approach and it doesn't seem to work. Our reports still pop up the Database Logon screen with a request for a User Id and Password. Were you able to store the User Id in the registry as well? How does the InteractiveViewer.asp file know to look in the registry for these values?

Thanks,
Bryan
 
I found a way in to modify your viewers code to harcode the password and login name so it doesn't prompt your users. This is taken from another thread. it worked great for me and i used it in both the interactive and page viewer asp files. good luck!
Dean

Using the URL I can tell the RAS what report I want to open and it will only prompt for the parameters because I’ve already issued the connection string.

The URL looks like this:
http:\\RAS\cr\interactiveViewer.asp?reportname=drawing bom.rpt

The only thing you’ve got to add is the following:

Dim userName, password
userName = "your_username"
password = "your_password"

clientDoc.DatabaseController.Logon username, password

Hope this helps.

Here's the full interactiveViewer.asp file ...

<%@ Language=VBScript CodePage=65001 ENABLESESSIONSTATE = False %>
<% Option Explicit
' Note - the CodePage=65001 is needed to display Unicode text correctly in the viewer
' if Session is null for ProcessHttpRequest

'1. Create the ObjectFactory to instantiate Crystal Objects
Dim objectFactory
Set objectFactory = CreateObject(&quot;CrystalReports.ObjectFactory.2&quot;)

Response.ExpiresAbsolute = Now() - 1

'2. Create Viewer
Dim viewer
Set viewer = objectFactory.CreateObject(&quot;CrystalReports.CrystalReportInteractiveViewer&quot;)
viewer.Name = &quot;page&quot;
viewer.IsOwnForm = true
viewer.IsOwnPage = true

'3. Get the Report
Dim theReportName
theReportName = Request.Form(&quot;ReportName&quot;)
if theReportName = &quot;&quot; then theReportName = Request.QueryString(&quot;ReportName&quot;)
viewer.URI = &quot;interactiveViewer.asp?ReportName=&quot; + Server.URLEncode(theReportName)

'4. Create the ReportClientDocument
Dim clientDoc
Set clientDoc = objectFactory.CreateObject(&quot;CrystalClientDoc.ReportClientDocument&quot;)
clientDoc.Open theReportName

'5. User name and Password Variables
Dim userName, password
userName = &quot;your_username&quot;
password = &quot;your_password&quot;

clientDoc.DatabaseController.Logon username, password

viewer.ReportSource = clientDoc.ReportSource
'viewer.EnableLogonPrompt = false



Dim BooleanSearchControl
Set BooleanSearchControl = objectFactory.CreateObject(&quot;CrystalReports.BooleanSearchControl&quot;)
BooleanSearchControl.ReportDocument = clientDoc
viewer.BooleanSearchControl = BooleanSearchControl
viewer.ProcessHttpRequest Request, Response, Null
' ReportClientDocument will be automatically closed when clientDoc is released
%>

 
I tried adding this:

Dim userName, password
userName = &quot;your_username&quot;
password = &quot;your_password&quot;

clientDoc.DatabaseController.Logon username, password

to my InteractiveViewer.asp file as well as the partsviewer and pageviewer files, but it didn't seem to work. I still get prompted for this info. Got any further advice? I am using CE9 RAS ePortfolio Lite, BTW.

Thanks,
Bryan
 
Below is the exact code from my pageviewer.asp file. just type in your username and password and see if that works. Our database server is MS SQL. I'm not sure this works the same way for other db servers. i would copy the code exaclty line for line if you can.

<%@ Language=VBScript CodePage=65001 ENABLESESSIONSTATE = False %>
<% Option Explicit
' Note - the CodePage=65001 is needed to display Unicode text correctly in the viewer
' if Session is null for ProcessHttpRequest
Dim objectFactory
Set objectFactory = CreateObject(&quot;CrystalReports.ObjectFactory.2&quot;)

Response.ExpiresAbsolute = Now() - 1

Dim viewer
Set viewer = objectFactory.CreateObject(&quot;CrystalReports.CrystalReportViewer&quot;)
viewer.Name = &quot;page&quot;
viewer.IsOwnForm = true
viewer.IsOwnPage = true

viewer.ReuseParameterValuesOnRefresh = False
viewer.HasRefreshButton = true

Dim theReportName
theReportName = Request.Form(&quot;ReportName&quot;)
if theReportName = &quot;&quot; then theReportName = Request.QueryString(&quot;ReportName&quot;)
viewer.URI = &quot;pageViewer.asp?ReportName=&quot; + Server.URLEncode(theReportName)

Dim clientDoc
Set clientDoc = objectFactory.CreateObject(&quot;CrystalClientDoc.ReportClientDocument&quot;)
clientDoc.Open theReportName

Dim userName, password
userName = &quot;your username&quot;
password = &quot;your password&quot;
clientDoc.DatabaseController.Logon username, password

viewer.ReportSource = clientDoc.ReportSource
viewer.EnableLogonPrompt = false
'viewer.ReportSource = theReportName
viewer.ProcessHttpRequest Request, Response, Null
 
I copied in your entire pageviewer.asp file and still no luck. Maybe I would also need your complete interactiveviewer.asp and partsviewer.asp files for it to work? I did notice in editing my files that there were some small differences between our files.

Just for clarification, you are talking about the files in the &quot;reports&quot; directory on the RAS server, right?
 
yes it's for reports in the reports directory listed in the RAS configuration utility. I'm not sure i can help you if this is not working, i'm no expert myself, but this worked for me. if there is any difference in your file to my file, send me what your pageviewer.asp looks like and maybe i can spot the difference, if they are identical, then you might have other issues. I force my users to use the pageviewer.asp so i'm not using the interactive viewer but i tested it and it also worked.
 
This is what my pageviewer.asp file looks like (with the username and password marked out):

<%@ Language=VBScript CodePage=65001 ENABLESESSIONSTATE = False %>
<% Option Explicit
' Note - the CodePage=65001 is needed to display Unicode text correctly in the viewer
' if Session is null for ProcessHttpRequest

Dim objectFactory
Set objectFactory = CreateObject(&quot;CrystalReports.ObjectFactory.2&quot;)

Response.ExpiresAbsolute = Now() - 1

Dim viewer
Set viewer = objectFactory.CreateObject(&quot;CrystalReports.CrystalReportViewer&quot;)
viewer.Name = &quot;page&quot;
viewer.IsOwnForm = true
viewer.IsOwnPage = true

viewer.ReuseParameterValuesOnRefresh = False
viewer.HasRefreshButton = true

Dim theReportName
theReportName = Request.Form(&quot;ReportName&quot;)
if theReportName = &quot;&quot; then theReportName = Request.QueryString(&quot;ReportName&quot;)
viewer.URI = &quot;pageViewer.asp?ReportName=&quot; + Server.URLEncode(theReportName)

Dim clientDoc
Set clientDoc = objectFactory.CreateObject(&quot;CrystalClientDoc.ReportClientDocument&quot;)
clientDoc.Open theReportName

Dim userName, password
userName = &quot;xxxxx&quot;
password = &quot;xxxxx&quot;
clientDoc.DatabaseController.Logon username, password

viewer.ReportSource = clientDoc.ReportSource
viewer.EnableLogonPrompt = false
'viewer.ReportSource = theReportName
viewer.ProcessHttpRequest Request, Response, Null

%>
 
the script looks correct. Are you connecting to a SQL database via an ODBC data source?
when you are prompted for a username and password, when you type it in manually, doesn't it process the report correctly? if it's a case sensitive password you have to type it exactly that way in the asp file with quotes around it. other than that, i'm at a loss. Sorry
 
I am running against SQL Server and it is an ODBC connection. The report does run correctly when a userid and password are entered manually.

I may try to play around with it a little to see if I can get things to work. Thanks for your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top