Solved Need help with using the debugger
-
These is the errors that i have, i don´t know if these errors be of ide or to my errors
-
Hi and welcome to devnet,
You have at least one flaw in your code flow. You won't reach the
if (existe > 0)
line because if your condition becomes true you callreturn true;
after settingexiste
to 1. -
Thank you for your answer , but in one of the images inside the cycle “while”it goes into “if”and then gets back true but never goes out of function
If you want to watch the mistake I can show you in a video
-
Can you explain that more precisely ? If the
if
statement of yourwhile
loop goes through then you will return early. -
I do not speak much English and it helped me with the google translator but the question is:
When entering my username and password that are correct according to the query, the user finds me and I would have to return true, but doing the 2 things returns true and false at the same time.
Because the Boolean function when it returns true does not leave the function but it continues with the code that is below and also returns false, that is my error, I mean true and false return at the same time and it does not have to happen according to the language .
If you want to see my error more thoroughly I made a video.
-
Are you sure your method is not called twice ?
-
if because if you look at the image where I have the conditional where that conditional is called is the only place where the function is called, not if you saw the video? there is how it works, it returns me at the same time true and false, try to uninstall qt and then reinstall it and stay the same
-
A function can't return twice. Hence my question of a double connection or that function called twice from maybe different places in your code.
-
That's what I wonder, because the function I do not call it twice and if it was then I would always return true because the user exists and returns true but never leaves the function and returns to me but this time false
-
Try an alternative implementation:
bool found = false; while (query.next()) { if (/* conditions*/) { found = true; break; } } if (!found) { /* show your dialog */ } return found;
By the way, why are your re-creating the database connection each time you call your functions ?
-
Well, I just did something that I think I should not do but I passed all my class to a dynamic library using certain #ifdef parameters and I started to play with the compiler a bit but I do not know if that would hurt me at the time of package the program in an installer that I put it so that my code is compiled in good execution time that is my logic that if I leave this error in doubt because it passes and test your suggestion but I take the variable as constant I do not know why
And thanks
-
or if and with respect to why I re-create the connection is because I was not throwing an error something strange that at the time of executing the query I could not find the database and so far I do not know why, I have had many problems with sqlite I had already worked with mysql but right now with sqlite has given me many strange problems like for example right now I have a query that I do the same in all the tables that is to insert but when I want to insert it to that table it throws me the error of parameter count mismatch and I'm trying to solve because I get that error
-
When deploying your application you will have to deploy the Qt libraries anyway so having an additional library should really not be a problem.
As for the parameter count mismatch, any chance that you are using named placeholders ? If so, please update to Qt 5.10, the SQLite backend has complete support for it since that version.
-
Thanks for the help right now I am downloading the update of 5.10, but only by cursiodad, what is the best way to make a portable database with the QT, because my decision had been SQLITE because it created a file as a database to me I would like this because the application I want to be able to take your database to another machine and then import it with my application, because my application will work offline, I do not want it to be connected to another server or that the client has to install other things so that it works for you, suppose SQL SERVER or MYSQL does not, I want it to be portable and that when the client can export a database it can take a file with all the information and all the records and then import it into another machine
And thanks for your time in answering me, whenever you want I have a case pack 1500 icons for buttons and other things
-
You can dump the content of a Postgresql/MySQL database into a file if wanted and load that file again on another instance however that still means that you have to have one of these server running somewhere accessible.