1. Sergio Ciordia
  2. Valentina Reports ADK
  3. Суббота, Май 18 2019, 10:21 AM
  4.  Подписаться через email
Hi,

I am using the files from GeneralOnVSQLite example to understand how to get a VReport. The SQLite is in the VSQLite Server and the reports.vsp is in local. This is my code in Xojo Project:

[App]
- Close Event Handler
Valentina.ShutDownClient()

- Open Event Handler
Valentina.InitClient()
mProjectPath = getFolderItem( "reports.vsp" )
If mProjectPath.Exists Then
mProject = new VProject(mProjectPath)
mProject.Open()
Else
MsgBox("The report does not exist.";)
End If

//Connect to vsqlite server
gClient = true //Server Mode
If gClient = true Then
vconnect="vsqlite_server://host=82.223.82.22 port=15532 dbname='reports_db.sqlite' user='xxx' password='yyy'"
Else
End If

[Global Properties]
Dim gClient As Boolean
Dim mProject As VProject
Dim mProjectPath As FolderItem
Dim mReport As VReport
Dim vconnect As String

[Print button: Action Event]
try
mReport = mProject.MakeNewReport(1, vconnect, "SELECT * FROM T1";) //VException: ErrorNumber 365829

exception err as VException
dim errNumber as Integer = err.ErrorNumber
dim errString as String = err.Message
end

if mReport <> nil then

dim f as FolderItem = GetSaveFolderItem("*.pdf", "my_report.pdf";)
mReport.PrintToDisk( f, EVReportPrintType.kToPDF )

//launch the file in the default viewer on your system for _.pdf_ files
f.Launch

end if

Could you help me, please?. What I am doing wrong?

Thank you very much.
Sergio
Комментарий
There are no comments made yet.
Sergey Pashkov Ответ принят
Hello Sergio,

For local reports, it is necessary to add reports initialization to Open event:
Valentina.InitReports( macSerial, winSerial, linSerial )

And Close event:
Valentina.ShutdownReports
Комментарий
There are no comments made yet.
Sergio Ciordia Ответ принят
Thanks Sergey,

I have added Valentina.InitReports and Valentina.ShutdownReports in open and close events but I get this error message when I run the project: "An exception of class VException was not handled. The application must shut down. Exception Message: Sqlite db "reports_db.sqlite": Error : "near "SELECT": syntax error". Exception Error Number: 427264"

Could you help me again, please?

Sergio
Комментарий
There are no comments made yet.
Sergey Pashkov Ответ принят
Is it a report from examples?

If it is working fine in Valentina Studio you can try to pass an empty query - it will be loaded from the project.
Комментарий
There are no comments made yet.
Sergio Ciordia Ответ принят
Hi Sergey,

my report works perfectly in Valentina Studio but I cannot run in Xojo. Could you check it, please?. I attach my Xojo project and the Vreport used.

Thank you very much.
Sergio
Вложения
Комментарий
There are no comments made yet.
Sergey Pashkov Ответ принят
Thank you, I reproduced the problem. We'll recheck it shortly.
Also, if you pass an empty string - the query is loaded from the project and it works in this case.
Комментарий
There are no comments made yet.
Sergio Ciordia Ответ принят
Thank Sergey.

Maybe I can help you. When I load an empty query the project doesn't work immediately, in debug mode I have checked that initially the mreport variable has the pagecount value to 0 but after a few seconds it goes to pagecount 1 and then the report is generated as an empty pdf. If I load the previous query (Select * from T1) the same thing happens, until pagecount is not equal to 1 the report is not generated but it is also empty. I hope it helps you to detect the problem.

I hope you can fix it soon ;) .

Sergio
Комментарий
There are no comments made yet.
Sergey Pashkov Ответ принят
Hello Sergio,

Could you please try to remove the query completely, including quotes, and type it again? Will it work?

The initial problem was is that query somehow contains the UTF-8 byte order mark (3 bytes, EF BB BF), and it breaks the SQLite lexer.
After retyping the query I was able to get the report.
We can add protection against it, but it is better to understand how was this string created.
Комментарий
There are no comments made yet.
Sergio Ciordia Higuera Ответ принят
Thank you very much Sergey.

I have typed again the query completely and now it works. I don't understand it. I download this example from other discussion post: https://valentina-db.com/en/discussion-forums/5265-running-valentina-reports

You uploaded the file yourself Sergey. I downloaded the zip file from the link at the end of that post. I just modified some things in the code to adapt it to my project.
In any case, thank you very much for reviewing and finding the error, it was not easy. ;)

Best regards,
Sergio
Комментарий
There are no comments made yet.
  • Страница :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.

Categories

Announcements & News
  1. 0 subcategories
Valentina Studio
  1. 2 subcategories
Valentina Server
  1. 4 subcategories
Valentina Database ADK
  1. 0 subcategories
Valentina Reports ADK
  1. 0 subcategories
Other Discussions
  1. 2 subcategories
BETA Testing
  1. 0 subcategories
Education & Research
  1. 0 subcategories