In this post I will show you how to fix an error that appears in my thermal printer plugin that says: Error en el servidor: sql: no rows in result set.
This error says that there are no rows in the database, and you may be wondering what printing has to do with a database, so that is exactly what I will discuss in this post.
In the first versions of the plugin, there was the option called setImpresora
that was to set the printer in which the tickets would be printed by default. Once established, that printer name was stored in a SQLite3 database.
This error is caused because there is no data in the database because you have not invoked setImpresora
, so when you try to print it gives you that error because there is no data in the database (there are no rows, that simple).
Later I implemented the imprimirEnImpresora
function that allows you to specify which printer to use when printing, by sending it the printer name as a string.
I have always recommended using the imprimirEnImpresora
method instead of the end
method to finish the print job, in this way you take care of saving the name of the printer and passing it to the plugin when printing.
So to fix this problem, don’t do this, this is wrong:
let impresora = new Impresora(RUTA_API);
impresora.setFontSize(1, 1);
impresora.write("Fuente 1,1\n");
impresora.setFontSize(1, 2);
impresora.write("Fuente 1,2\n");
impresora.setFontSize(2, 2);
impresora.write("Fuente 2,2\n");
impresora.setFontSize(2, 1);
impresora.write("Fuente 2,1\n");
impresora.setFontSize(1, 1);
impresora.setEmphasize(1);
impresora.write("Emphasize 1\n");
impresora.setEmphasize(0);
impresora.write("Emphasize 0\n");
impresora.setAlign("center");
impresora.write("Centrado\n");
impresora.setAlign("left");
impresora.write("Izquierda\n");
impresora.setAlign("right");
impresora.write("Derecha\n");
impresora.setFont("A");
impresora.write("Fuente A\n");
impresora.setFont("B");
impresora.write("Fuente B\n");
impresora.feed(2);
impresora.write("Separado por 2\n");
impresora.cut();
impresora.cutPartial(); // Pongo este y también cut porque en ocasiones no funciona con cut, solo con cutPartial
impresora.end()
.then(valor => {
loguear("Al imprimir: " + valor);
});
Do this, this is right:
let impresora = new Impresora(RUTA_API);
impresora.setFontSize(1, 1);
impresora.write(`Tratando de imprimir en ${nombreImpresora}
`);
impresora.write(mensaje);
impresora.cut();
impresora.cutPartial(); // Pongo este y también cut porque en ocasiones no funciona con cut, solo con cutPartial
impresora.imprimirEnImpresora(nombreImpresora)
.then(valor => {
loguear("Al imprimir: " + valor);
});
The difference is that I am invoking imprimirEnImpresora
by passing the printer name, and not just the end
method.
Another solution is to simply invoke setImpresora
. Most of the time this problem occurs because the client uses the free plugin and calls setImpresora
correctly; It works for him and he buys the premium version, but when using the premium version he forgets to invoke setImpresora
, so he gets the error sql: no rows in result set.
You can do two things: invoke the setImpresora
method again with the name of your printer, or start using the imprimirEnImpresora
method instead of the end
method.
In the last months I have been working on a ticket designer to print on…
In this post you will learn how to use the Origin Private File System with…
In this post you will learn how to download a file in the background using…
In this post I will show you how to use SQLite3 directly in the web…
In this tutorial, we'll explore how to effortlessly print receipts, invoices, and tickets on a…
When printing receipts on thermal printers (ESC POS) sometimes it is needed to print images…
Esta web usa cookies.