Free knowledge blog: linux, programming, open source, databases, android, frameworks, web and computing in general
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:
Do this, this is right:
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.