Article ID 2173
Article Title INFO: LogOnServer needs password set using PESetNthTableLogOnInfo
Article URL http://www.dataaccess.com/kbasepublic/kbprint.asp?ArticleID=2173
KBase Category Crystal Reports
Date Created 09/26/2005
Last Edit Date 09/26/2005


Article Text
PROBLEM:
The help on LogOnServer says that the "SQL option of CrystalReport [class/object] is required".  What does that mean? Is there an option in the class to make LogOnServer work in VDF?

I am trying to use LogOnServer with a report using ADO and I get the error "Unable to connect: incorrect log on parameters".

SOLUTION:
The Help statement needs to be adjusted because the only thing needed by the report to access an SQL database is an SQL driver.

This "SQL option" mentioned in the help refers to the edition of Crystal Reports being used since Crystal itself needs to be of an edition that supports accessing SQL databases. Up to Crystal 8.5, you needed Crystal Developer or Professional edition in order to access SQL databases - see http://www.businessobjects.com/global/pdf/products//crystalreports/crxi_feat_ver_ed.pdf.


Regarding the error message you see when using the ADO driver, that error can be displayed when using DataFlex files as well - see Kbase 1907 - ERROR: "Unable to connect: incorrect log on parameters" (http://192.245.64.8/ KBPrint.asp?ArticleID=1907) - if the location of the file is wrong.

For some Crystal (crpe32.dll) reason, the password passed along LogOnServer is not being used when running the report. This is not a bug in Visual DataFlex; it is just the way Crystal works. Apparently, even though Crystal's PELogOnServer function takes password as a parameter, it does not seem to use it and, in order to run the report, the password must be set.

From the Help (legacy.chm) - Crystal 10 Developer does not have that in its help. If you have Crystal 9 Developer, you can look for this reference:
- Password is undefined when getting information from the report.
- Password must be set using PEGetNthTableLogOnInfo*. You can pass an empty string ("") for ServerName, DatabaseName, or UserID, and the program will use the value that's already set in the report. If you want to override a value that's already set in the report, use a non-empty string (for example, "Server A") for the other parameters as well.

* PEGetNthTableLogOnInfo should read PESetNthTableLogOnInfo


As a solution, you can still use LogOnServer to get all the other parameters (server, database and user) set for the report and use 'set NthTableLogOnPassword 0 to "password" 1' to set the password for the report for all the tables at once - as KBase 1264 explains:

//---------------------------------------
Additional Notes:
For Visual DataFlex version 8 and higher, NthTableLogOnXXX will require an additional parameter - iPropagateAcrossTables (0 - not to propagate; 1 - to propagate). The propagate flag may be used to affect all tables with similar server and database properties.

          Set NthTableLogOnServerName iCounter To "server" 0
          Set NthTableLogOnDatabaseName iCounter To "database" 0
          Set NthTableLogOnUserId iCounter To "username" 0
          Set NthTableLogOnPassword iCounter To "password" 0

//---------------------------------------



You can subclass the CrystalReport class and add a "Set NthTableLogOnPassword" to the LogOnServer in the subclass. Another alternative is to simply augment LogOnServer - for example:

Procedure LogOnServer String sDLLName String sServerName String sDatabaseName String sUserID String sPassword

            Forward send LogOnServer sDLLName sServerName sDatabaseName sUserID sPassword

            Set NthTableLogOnPassword 0 to sPassword 1

End_Procedure


You can also do something like what the attached example illustrates.






Contributed By:
Marcia Booth
Company: Data Access Worldwide
Web Site: http://www.dataaccess.com

Links Related to this Article
Crystal Reports Features
File LogOnServer_Example.zip
DAW Knowledge Base article 1264: HOWTO: Run Crystal Reports report using DB2 / MSSQL database from VDF
DAW Knowledge Base article 1907: ERROR: "Unable to connect: incorrect log on parameters"

Email this Article
Email this Article to a Colleague
Send Feedback on this Article to Data Access Worldwide
Copyright ©2024 Data Access Corporation. All rights reserved.

The information provided in the Data Access Technical Knowledge Base is provided "as is" without warranty of any kind. Data Access Corporation disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. In no event shall Data Access Corporation or its suppliers be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages, even if Data Access Corporation or its suppliers have been advised of the possibility of such damages. Some states do not allow the exclusion or limitation of liability for consequential or incidental damages so the foregoing limitation may not apply.