New to JSReport and Tutorial isn't working
-
HI !
I am new to jsreport and I only start to download it yesterday. I am using this page as reference: https://jsreport.net/blog/pdf-reports-in-sql-serverso I can get data from database, however the document is blank and I got this :
here is my code (I'm not really changing it):
This is really stressed me out... please help me..
Am I doing something wrong here ?
-
Hi,
there are some breaking changes in jsreport v2 which were not propagated to that blog post.
I tried to update it now.The main difference is that the scripts
beforeRender
function has different signature.
This should work.const sql = require('mssql'); const config = { "user": "jsreport", "password": "password", "server": "janblaha-PC\\SQLEXPRESS", "database": "northwind" } async function beforeRender(req, res) { await sql.connect(config) const sqlReq = new sql.Request(); const recordset = await sqlReq.query( `select count(*) as Count, ShipCountry from Orders group by ShipCountry` ) Object.assign(req.data, { countries: recordset }); }
-
Hi, thank you for fast response...
I tried it but I still can't show the data from database table...do you have any suggestion ?
thank you so much
-
do you see some different error error after changing the code or do you see the same?
can you share the new code that you have now (just to double check that you don't have some mistake)?
-
Hi, I'm new to jsreports and I have the same problem. It seems to be recovering from the database but it does not show it. In my database I have 4 data and this matches the foreach that shows 4 times the ID but does not show its values. I am applying the code of jan_blaha.