ۥ-x@ -4    '7By@4 Crystal Reports Technical Document Subject: Logging onto Server - uses and description of PE Calls Date: August 24, 1993 Versions: 2.0 Pro or VB upgrades to 2.0 Pro Situation: When logging on to a SQL Server there are basically two options that you can choose from. An explicit logon(PELogOnServer) or an implicit logon(PESetNthLogonInfo). This document will describe the uses of both scenarios and demonstrate there uses within Visual Basic sample code. Solution: Explicit Logon PELogOnServer The explicit API call is used to log on to a specified server and it will return a value of TRUE(1)if he call is successful and FALSE(0)if something goes wrong. The appropriate time to use such a call would be when logging on to a specified server at runtime in response to user input. For example, a user could input a specified ServerName, DatabaseName, UserID and Password. However, when a report is created using SQL Tables all of the previous information will be stored in your report except for the password. Therefore, when you initialize the structure, as shown below, you can leave each structure blank(i.e " ")except for the password. For NetWare SQL, pass the dictionary path name in ServerName and data path name in DatabaseName. Visual Basic Code for PELogOnServer Dim DLLName As String Dim LogOnInfo As PELogOnInfo DLLName = "PDSSYBAS.DLL" 'the DLLName is the name of the Crystal Reports DLL for the Server you want to log on to. 'DLLName for SQL/Sybase is PDSSYBAS.DLL 'DLLName for Oracle(Q+E) is PDSORACL.DLL 'DLLName for NetWare SQL is PDSNETW.DLL 'DLLName for Gupta is PDSGUPTA.DLL 'DLLName for SQL Sever(ODBC),or any other ODBC connection, PDSODBC.DLL 'Initialize the structure LogOnInfo.Structsize = PE_SIZEOF_LOGON_INFO LogOnInfo.ServerName = "ServerName" + Chr$(0) LogOnInfo.DatabaseName = "DatabaseName" + Chr$(0) LogOnInfo.UserID = "UserID" + Chr$(0) LogOnInfo.Password = "Password" + Chr$(0) 'if you want to use the logoninfo stored in your report then leave all of the above 'blank(i.e " ") but the password. Crystal Reports does not store this password input. If PELogOnServer(DLLName, LogOnInfo) = false then MsgBox("Connection to Server was unsuccessful) Else MsgBox("Connection to Server was Successful) ' Do Work(other PE calls) If PELogOffServer (DLLName, LogOnInfo) = false then MsgBox("Unable to disconnect from Server") End if Comments: SYMBOL 183 \f "Symbol" \s 10 \h We recommend that you leave the structure size as PE_SIZEOF_LOGON_INFO which is defined in Global.BAS. SYMBOL 183 \f "Symbol" \s 10 \h PELogOnServer can be called at any time to log on a database. This function is not required if the function PESetNthTableLogOnInfo was already used to set the password for the table. SYMBOL 183 \f "Symbol" \s 10 \h This function requires the user to know the database DLLName SYMBOL 183 \f "Symbol" \s 10 \h This function can also be used for NonSQL tables, such as password-protected Paradox tables. Call this function to set the password for the Paradox DLL before beginning printing. SYMBOL 183 \f "Symbol" \s 10 \h When printing using PEStartPrintJob, the ServerName passed in PELogServer must agree exactly with the server name stored in the report. If this is not true use PESetNthTableLogOnInfo to perform the logging on instead. PELogOffServer This Print Engine call is similar ot PELogOnServer. An example is shown in the previous code. Implicit Logon This type of logon will allow the user to access the appropriate log on information from a report table(PEGetNthTableLogOnInfo) and then allows the user to set the password or change any of the log on parameters(PESetNthTableLogOnInfo) PELOGONS.DOC PP ,.09V^csu  . / u v /.24=   6.0<TVacsumoBk+-Hu) + > D t v   u 硔 0!h 0!h 0!h0!0!"  0!p 0!$ 0! T0!0! :-/*,.0240!0!0!0! 0!!$2B +"MO4= 4 BTimes New Roman Symbol&Arial5Courier New 1Courier  ;  U u + K 99999 "hEcece C Logging onto Server; PE CallsTechnical Support Document PELogonServer_Description and uses of PE calls to logon to server, get & set logon info. VB examples of each.Mark A Cunningham Gurdeep Birdi