Article ID 1264
Article Title HOWTO: Run Crystal Reports report using DB2 / MSSQL database from VDF
Article URL http://www.dataaccess.com/KBasePublic/KBPrint.asp?ArticleID=1264
KBase Category Crystal Reports
Date Created 01/25/2001
Last Edit Date 07/01/2004


Article Text
To be able to run a report that uses DB2 or MS SQL Server as the database from a VDF application, you will need to provide the logon information through one of the commands listed below:

- LogOnServer
This is easier to call than the NthTableLogOn properties and it can be called at any time. You must know the database DLL name to make this call.

- NthTableLogOn properties
These are more flexible than LogOnServer since they allow you to override any of the log on parameters. These properties must be called from the OnInitializeReport procedure.


Example:
// Setting the logon parameters using the LogOnServer procedure
   Procedure OnInitializeReport
      Send LogOnServer "p2sodbc.dll" "server" "database" "username" "password"
   End_Procedure // OnInitializeReport

// Setting the logon parameters for each table using the NthTableLogOn properties
   Procedure OnInitializeReport
      Integer iTables iCounter

      Get NTables To iTables
      For iCounter From 0 To (iTables-1)
          Set NthTableLogOnServerName iCounter To "server"
          Set NthTableLogOnDatabaseName iCounter To "database"
          Set NthTableLogOnUserId iCounter To "username"
          Set NthTableLogOnPassword iCounter To "password"
      Loop
   End_Procedure // OnInitializeReport


If you are not sure what the DLL name is or what logon information to use, you can get those from the report itself:
- From the Designer, open your report

- Select Database \ Convert Database Driver
Here you will find the name of the DLL being used. The name displayed has a D as the second character but the DLL name will have a 2 instead of a D - only 16-bit DLLs have their file name using D.
e.g.: If pdsodbc.dll is displayed, the name of the file you will need to inform is p2sodbc.dll

- Select Database \ Set Location
From here you can get the logon information

Note1:
The report against a DB2 database can be built using the ODBC Driver (p2sodbc.dll, displayed as pdsodbc.dll ) or the DB2 Native Driver (p2sdb2.dll, displayed as pdsdb2.dll). They will both need the same logon information to be provided.

Note2:
If the error message "Cannot open SQL server" is displayed, the logon was not successful. Check your logon information and the command used.

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



Contributed By:
Ulbe Stellema
Company: Data Access Worldwide
email: ulbe.stellema@dataaccess.eu
Web Site: http://www.dataaccess.eu

Links Related to this Article
DAW Knowledge Base article 2020: INFO: What is the difference between LogOnServer and NthTableLogOn?

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.