1. ciro marciano
  2. Valentina Reports ADK
  3. Wednesday, May 25 2016, 09:26 AM
  4.  Subscribe via email
Hi! Following this tutorial

http://valentina-db.com/docs/dokuwiki/v6/doku.php?id=valentina:vcomponents:vreport:tutorials:generating_reports_from_xojo_web_application

I made a simple project, but I'm not able to view the pdf result.
If I put in the action event of a button this...

msgbox("CIAO";)
Try

// Open connection
Dim conn As VConnection = New VConnection( "127.0.0.1", "sa", "sa" )
conn.Open

// Open server project
'Dim projPath As FolderItem = GetFolderItem( "xojo_web_reports.vsp" )
Dim projPath As FolderItem = GetFolderItem( "xxx.vsp" )

Dim proj As VProject = New VProject( conn, projPath )
proj.Open

// Print report as PDF to RAM
Dim datasource As String = "vserver://host='localhost' port='15432' dbname='valentina_sakila' user='sa' password='sa'"
Dim report As VReport = proj.MakeNewReport( "Report_Actors", datasource, "SELECT * FROM actor" )
Dim data As String = report.PrintToBuffer( EVReportPrintType.kToPDF, 1 )

// Prepare download
mPDF = New WebFile
mPDF.MimeType = "application/pdf"
mPDF.FileName = "report.pdf"
mPDF.ForceDownload = False
mPDF.Data = data

// Close project and connection
proj.Close
conn.Close

// Show PDF in browser
ShowURL( mPDF.URL )

Exception err As VException
Dim errNumber As Integer = err.ErrorNumber
Dim errString As String = err.Message
msgbox(errString)
End


I can see the msgbox if is the only instruction inside, otherwise nothing happens (no errors or messages....).
Where's the problem??
Comment
There are no comments made yet.
Sergey Pashkov Accepted Answer
Hi Ciro,

This sample worked for me - I've attached the project.

Can you debug this action step by step, maybe it will give some hint?
Attachments (1)
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 1
ciro marciano Accepted Answer
So, this is what I did:

make a new Vstudio project with mssql server (now, with your last build it works!!).
Test the report in preview, everything is fine.

Go back to xojo 2016 r.1.1 (please note I'm working on a non registered version for now, so I cannot compile, but run)

This is what I've in the action event of a button to launch report (please read comments in UPPERCASE) but clicking it nothing happens

Strange is that neither the msgbox appears!! (if I leave it as unique line of the event, yes it shows itserf)

msgbox("CIAO";)
Try

// Open connection
Dim conn As VConnection = New VConnection( "127.0.0.1", "sa", "sa" ) << DO I NEED THIS? I'M NOT USING VSERVER!
conn.Open

// Open server project
Dim projPath As FolderItem = GetFolderItem( "e:\xojo\elenco_alunni.vsp" )

Dim proj As VProject = New VProject( conn, projPath )
proj.Open

// Print report as PDF to RAM
Dim datasource As String = "vserver://host = '192.168.7.201\SQL2008R2', user = 'sa', password = 'TaRGeT1997', db = 'SCUOLE_2016' "
Dim report As VReport = proj.MakeNewReport( "Report_Actors", datasource, "SELECT * FROM ANA_STUD" )
Dim data As String = report.PrintToBuffer( EVReportPrintType.kToPDF, 1 )

// Prepare download
mPDF = New WebFile
mPDF.MimeType = "application/pdf"
mPDF.FileName = "report.pdf"
mPDF.ForceDownload = False
mPDF.Data = data

// Close project and connection
proj.Close
conn.Close

// Show PDF in browser
ShowURL( mPDF.URL )

Exception err As VException
Dim errNumber As Integer = err.ErrorNumber
Dim errString As String = err.Message
msgbox(errString)
End
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 2
Sergey Pashkov Accepted Answer
Hi Ciro,

No, you don't need to create VConnection in this case, just pass the project location into constructor:

Dim proj As VProject = New VProject( projPath )


And a datasource string:

Dim datasource As String = "mssql://host = '192.168.7.201\\SQL2008R2', user = 'sa', password = 'TaRGeT1997', dbname = 'SCUOLE_2016'"
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 3
ciro marciano Accepted Answer
Ok,

now I'm getting an error on this line...

Dim report As VReport = proj.MakeNewReport( "Report_Actors", datasource, "SELECT * FROM ANA_STUD" )

I assume that the datasource is ok and the query "SELECT * FROM ANA_STUD" is the same I used in the report created with Vstudio (and saved as query_1)
I think that the name "Report_Actors" is equivalent to whatever I want as name, tried also with report_1...but no way!
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 4
Sergey Pashkov Accepted Answer
Is error message still not shown?

If not shown - can you please set a breakpoint at marked line


Exception err As VException
Dim errNumber As Integer = err.ErrorNumber
Dim errString As String = err.Message <<<<<<
msgbox(errString)


and see, the value of errNumber?
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 5
ciro marciano Accepted Answer
the value is 365829
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 6
Sergey Pashkov Accepted Answer
Is this project opened in Valentina Studio at the same time? Can you try to close it?
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 7
ciro marciano Accepted Answer
yes, it was opened, closed it but still have error 365829
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 8
Sergey Pashkov Accepted Answer
Now you have:

Dim proj As VProject = New VProject( projPath )
proj.Open


right?
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 9
ciro marciano Accepted Answer
Dim proj As VProject = New VProject(projPath )

proj.Open
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 10
ciro marciano Accepted Answer
any news?
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 11
Sergey Pashkov Accepted Answer
Not yet, I'm checking it right now
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 12
ciro marciano Accepted Answer
by the way, this is the entire event code...

msgbox("CIAO";)
Try


// Open server project
Dim projPath As FolderItem = GetFolderItem( "e:\xojo\elenco_alunni.vsp" )

Dim proj As VProject = New VProject(projPath )
proj.Open

// Print report as PDF to RAM
Dim datasource As String = "vserver://host = '192.168.7.201\SQL2008R2', user = 'sa', password = 'TaRGeT1997', db = 'SCUOLE_2016' "
Dim report As VReport = proj.MakeNewReport( "Report_1", datasource, "SELECT * FROM ANA_STUD" )
Dim data As String = report.PrintToBuffer( EVReportPrintType.kToPDF, 1 )

// Prepare download
mPDF = New WebFile
mPDF.MimeType = "application/pdf"
mPDF.FileName = "report.pdf"
mPDF.ForceDownload = False
mPDF.Data = data

// Close project and connection
proj.Close
'conn.Close

// Show PDF in browser
ShowURL( mPDF.URL )

Exception err As VException
Dim errNumber As Integer = err.ErrorNumber
Dim errString As String = err.Message
msgbox(errString)
End
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 13
Sergey Pashkov Accepted Answer
Datasource string is not correct.

Found an issue - when the type of project deployment is changed - from server to local project, it is necessary to change Valentina init method - from Valentina.InitClient to (in the current case when SQL Server is used) Valentina.InitReports

So you can go to App and change Open event to:
Valentina.InitReports

Close event to:
Valentina.ShutdownReports
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 14
ciro marciano Accepted Answer
tried, now I'm getting error 532480, the line is the same

Dim report As VReport = proj.MakeNewReport( "Report_1", datasource, "SELECT * FROM ANA_STUD" )


:(
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 15
Sergey Pashkov Accepted Answer
Have you corrected a datasource string like was shown before?
Dim datasource As String = "mssql://host = '192.168.7.201\\SQL2008R2', user = 'sa', password = 'TaRGeT1997', dbname = 'SCUOLE_2016'"
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 16
ciro marciano Accepted Answer
corrected, new error 611604.....
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 17
Sergey Pashkov Accepted Answer
Now you can make step further in code and see the message in errString (or inside of VException err, of course).
There should be some message from SQL Server.
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 18
ciro marciano Accepted Answer
here it is:

Datasource error: "[FreeTDS] Unable to connect: 192.168.7.201\SQL2008R2 :: SCUOLE_2016

mmhhhh, could be the valentina reports from xojo (plugin) to be updated?
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 19
Sergey Pashkov Accepted Answer
Are host, user and password exactly the same like they are used in the Valentina Studio?
I can get this error only if some parameter is wrong.
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 20
  • Page :
  • 1
  • 2


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. 0 subcategories
BETA Testing
  1. 0 subcategories
Education & Research
  1. 0 subcategories
Omegabundle
  1. 0 subcategories