RE: GetSQLQuery NOT WORKING with Cry.Rep.5 & NewEra 2.2
Posted in 1997
Hi all Tim Wrote> >>Before migrating our NewEra applications to Ver 3. I realised that the >>classes with Crystal Reports Pro. 5 for NewEra would work with Ver 2.2 >>I've managed this ok. My test app. now prints a crystal report from >>within NewEra 2.2. >>There seems to be 2 problems. Firstly, GetSQLQuery is supposed to return >>the Query string from the report. Then SetSQLQuery can be used to change >>that SQL for the report at run time. GetSQLQuery is returning nothing. >>Does anyone know why? I have had the same problem, I have subsequently corrected the error, I think it has something to do with the order the functions are called in. For instance : Instantiate the engine object with the open parameter set to true, Open the report job with OpenJob(Filename), Output to a destination ie: OutPutToWindow(title,x,y,width,height,window style,containing window) Then you should be able to get and set the SQL string with GetSQLQuery() and SetSQLQuery(). The only thing I have done differently here is to use the native Informix driver supplied on the crystal reports web site. http://www.img.seagatesoftware.com. Click on 'What's hot' and continue clicking until you see the native Informix driver, download the zip file and extract it. Read the text file accompanying the driver on the installation and use, then use the following in your code: 1 - Instantiate the engine object with the open parameter set to true, 2 - Open the report job with OpenJob(Filename), 3 - Get the log on information for the first table used in your report,(I will assume that all the tables belong to the same database) getNthTableLogonInfo(0) - where 0 represents the id for the first table used in the report and 1 represents the second etc. This returns a variable of type CRPELogInfo (look it up in the help file) 4 - The code is as follows : CALL reportWN.CurJob.GetNthTableLogonInfo(0) RETURNING ok, reportWN.LogInfo LET reportWN.LogInfo.m_serverName = "Database Server Name" LET reportWN.LogInfo.m_databaseName = "Database Name" LET reportWN.LogInfo.m_userID = "informix" LET reportWN.LogInfo.m_password = "password" Set up the log on parameters, this is to bypass the ODBC driver. 5 - Next, log onto the server using the driver you downloaded as follows: LET ok = reportWN.Main_Engine.LogOnServer("P2SIFMX.dll",reportWN.LogInfo) Where P2SIFMX.dll is the native driver you can download. 6 - Output to a destination ie: OutPutToWindow(title,x,y,width,height,window style,containing window) 7 - Then you should be able to get and set the SQL string with GetSQLQuery() and SetSQLQuery(). There is a catch. You have to use the native driver with the report at creation time. Just log onto the server from within Crystal and click cancel until a logon server dialog appears, then choose the 'Informix Online Server' Option. This has to be done when you create a new report, it cannot be done afterwards. > > >>Second problem. Having used an earlier version of Crystal Reports with >>VB I know it had functions for printer selection. How do you do that >>through NewEra? The classes have a function PESelectPrinter - I can't >>understand how to use it! You are trying to call 'C' functions from New Era. They have New Era functions as wrappers for these 'C' routines. However I could not find the wrapper for this particular function either, I used embedded 'C' code to call the windows printer setup common dialog. If you find an easier way, please let me know. :) > >>Does anyone have an example of printer selection for NewEra? Not under the crystal engine. > >>This is one of the reasons for us using Crystal Reports without having >>to write 'c' code in our NewEra. If you use straight OLE - calling fully compiled crystal reports, a printer dialog appears for you to modify. Problem is, you cannot pass parameters when you use OLE (at least not as far as I can see). This was the reason for the creation of the class. Good luck and please let us know how you're doing :) David > > >david@west.co.za >Senior Software Consultant >The West Solutions Group >Friends help you move...REAL friends help you move bodies! >