Problem in Vreport

I got a error in Vreport As NilObjectException.

Dim pdfData As String = mReport.PrintToBuffer( EVReportPrintType.kToPDF, 1 )// In this line i got the error. Can anyone help me in this topic.

Thank You

VReport sounds like it would be related to Valentina database/reporting.

You are getting a NilObjectException because mReport is Nil, but we can’t say much more than that without seeing more code.

This is the code which i used to create a report in PDF Format using Valentina Studio & Sqlite
Dim f as FolderItem

[code]Try
f = GetFolderItem("").Parent.Child( “Report.vsp” )
mProject = new VProject( f )
mProject.Open()

Dim db_lite_location as FolderItem = getFolderItem("").Parent.Child( "NMCSProjDB.sqlite" )
Dim db_lite_path as string = db_lite_location.ShellPath
db_lite_path = ReplaceAll( db_lite_path, "\\ ", " " )
mDataSource_SQLite = "sqlite://" + db_lite_path

mReport = mProject.MakeNewReport(  "Report_Equipment", mDataSource_SQLite, "SELECT * FROM Equipment"  )

// MAKE  PDF in RAM
Dim pdfData As String = mReport.PrintToBuffer( EVReportPrintType.kToPDF, 1 )

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

mProject.Close

ShowURL(mPDF.URL)

Catch e as VException
dim errNumber as Integer = e.ErrorNumber
dim errString as String = e.Message
// … do something with this error.
// e.g. write it into log file or display on some HTML page
End

Dim pdfData As String = mReport.PrintToBuffer( EVReportPrintType.kToPDF, 1 ) // In this line i get the error[/code]

Edit (Paul): Put code in code block to make it easier to read

You should probably step through your code in the debugger to ensure it is not Nil to start with and to see if something changes it to Nil. I haven’t used Valentina Reports before, but could the line mProject.Close be causing mReport to become Nil?

Try

f = GetFolderItem("").Parent.Child( "Report.vsp" )
mProject = new VProject( f )
mProject.Open()

[b]// For Getting Data Dource[/b]
Dim db_lite_location as FolderItem = getFolderItem("").Parent.Child( "NMCSProjDB.sqlite" )
Dim db_lite_path as string = db_lite_location.ShellPath
db_lite_path = ReplaceAll( db_lite_path, "\\ ", " " )
mDataSource_SQLite = "sqlite://" + db_lite_path

// MAKE PDF in RAM
mReport = mProject.MakeNewReport( “Report_Equipment”, mDataSource_SQLite, “SELECT * FROM Equipment” )
Dim pdfData As String = mReport.PrintToBuffer( EVReportPrintType.kToPDF, 1 )
// Here i got the error as NilObjectException

// Prepare downloads
mPDF = New WebFile
mPDF.MimeType = “application/pdf”
mPDF.FileName = “report.pdf”
mPDF.ForceDownload = False
mPDF.Data = pdfData

mProject.Close

// Finally Pdf shown in Browser
ShowURL(mPDF.URL)

Catch e as VException
dim errNumber as Integer = e.ErrorNumber
dim errString as String = e.Message
// … do something with this error.
// e.g. write it into log file or display on some HTML page
End

Can anyone help me to sove this error.
Thank You

You’ll probably want to check the docs to see what can cause MakeNewReport to return Nil. Are you sure your path to the SQLite DB is valid?

Where is mReport declared? I think it needs to be in the session.

f = GetFolderItem("").Parent.Child( “Report.vsp” )

// Is f nil ?

mProject = new VProject( f )
mProject.Open()

// For Getting Data Dource
Dim db_lite_location as FolderItem = getFolderItem("").Parent.Child( “NMCSProjDB.sqlite” )
Dim db_lite_path as string = db_lite_location.ShellPath
db_lite_path = ReplaceAll( db_lite_path, "\ ", " " )
mDataSource_SQLite = “sqlite://” + db_lite_path

// MAKE PDF in RAM
mReport = mProject.MakeNewReport( “Report_Equipment”, mDataSource_SQLite, “SELECT * FROM Equipment” )

// Is mReport nil ? Can you get extended info about the error ? Read the manuals. Contact Valentina support.

Dim pdfData As String = mReport.PrintToBuffer( EVReportPrintType.kToPDF, 1 )
// Here i got the error as NilObjectException

// Prepare downloads
mPDF = New WebFile
mPDF.MimeType = “application/pdf”
mPDF.FileName = “report.pdf”
mPDF.ForceDownload = False
mPDF.Data = pdfData

mProject.Close

// Finally Pdf shown in Browser
ShowURL(mPDF.URL)

Catch e as VException
dim errNumber as Integer = e.ErrorNumber
dim errString as String = e.Message
// … do something with this error.
// e.g. write it into log file or display on some HTML page
End

I’ve the same problem, anyone solved it???

If you’re getting a NilObjectException check the paths to your reports and database in the debugger. If you’re getting a failure with no error make sure you’ve initialised Valentina reports using your license code (you should do this in your app’s start up).