Table of Contents
VProject Class: Report Factory Methods
To work with other database use another pair.
VProject.MakeNewReport(index)
Declaration:
MakeNewReport( inIndex as integer, inDatabase as VDatabase, inQuery as String = NULL, inCursorLocation as EVCursorLocation = kClientSide, inLockType as EVLockType = kReadOnly, inCursorDirection as EVCursorDirection = kForwardOnly ) as VReport
Parameters:
- inIndex - the index of a report in the range 1 .. ReportCount.
- inDatabase - The database that will be used as a data source.
- inQuery - The SQL string of a query or NULL to use query prepared by VStudio and stored in the VProject.
- inCursorLocation - The location of a cursor.
- inLockType - The lock type for records of a cursor.
- inCursorDirection - The direction of a cursor.
Description:
This method plays the role of a VReport class factory. It returns a VReport class instance for the Nth report of this project. It will return NULL if the specified report is not found.
- To create a report instance, the VREPORT DLL has to know:
Database that will be used to get data. Query that should be executed to get data. Can be NULL to use query stored in the VProject. Some optional parameters for this query.IMPORTANT: If the project is local then inDatabase can be both local and remote located on any Valentina Server. But if the project is hosted on a Valentina Server, then inDatabase MUST be hosted on the same server.
- Parameter inQuery must contain any SQL that returns a VCursor. Usually, this is a SELECT statement, although it can be a SHOW statement or a CALL procedure that returns cursor.
- Parameter inQuery can be NULL on default. In this case, the Report will use the original query, which is stored in the VProject, i.e. the same query that was used in the Report Editor, when this report was designed. You still can provide another query with the help of this parameter. For example, you can change the WHERE statement to select another record. In fact, you can use very different databases and tables, the only thing important is that the cursor should have fields with the same names as the report expects.
- Parameters inCursorLocation, inLockType, inCursorDirection are the same as for the VDatabase.SqlSelect() method. Please read details about them there.
IMPORTANT: When designing a report in Valentina Studio Pro, you assigned a SQL SELECT query to this report. You used the fields returned by that cursor to build the layout of this report. But that was during DESIGN mode.Now, in RUNTIME mode, you can provide a completely different database and use a completely different query. The only requirement is that the query used should produce a cursor with the same field names as the field names used by the report layout. If not the report will produce nothing for 'unmatched' fields.
Example:
dim theReport as VReport theReport = my_project.MakeNewReport( reportIndex, mDB, Query )
VProject.MakeNewReport(name)
Declaration:
MakeNewReport( inName as string inDatabase as VDatabase, inQuery as String = NULL, inCursorLocation as EVCursorLocation = kClientSide, inLockType as EVLockType = kReadOnly, inCursorDirection as EVCursorDirection = kForwardOnly ) as VReport
Parameters:
- inName - the name of a report.
- inDatabase - The database that will be used as data source.
- inQuery - The SQL string of a query or NULL to use query prepared by VStudio and stored in the VProject.
- inCursorLocation - The location of a cusror.
- inLockType - The lock type for records of a cursor.
- inCursorDirection - The direction of a cursor.
Description:
This method does the same as the above method, except that the report is specified by its name instead of by index. Please see the detailed description above.
Example:
dim index as Integer dim theReport as VReport theReport = my_project.MakeNewReport( "report_1", mDB, Query )