Good Morning in Spain.
First of all, thank you very much for the help.
The previous answer has helped me a lot and I have understood many things, but it still does not work, there is something that I do not do well or do not understand. What I do not understand is how I can have a project stopped for more than 1 month because I am not able to test an application on an iPhone physical device. An application that works correctly for me in xcode and everything is because of the database.
The steps I do are add the database to the project as indicated in the screenshots (photo1, photo2).Here I check that the database is really inside the project
Once this is done, I generate the database connection code, which is this
let fileURL = try! FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: false)
.appendingPathComponent("TurMer.sqlite")
Once this line is executed, it tells me that everything is correct. Moving on to execute the second line which is
if sqlite3_open(fileURL.path, &BaseDatos) != SQLITE_OK
In this line we have opened the database. Everything is correct, it tells me that the database exists (for that I have created a breakpoint)
Ok, at this point, we have found the database and opened it. Up to here everything correct.
Now we are going to execute a query in said database. I do it with the following code
cadenasql="SELECT * FROM Clientes"
var stmt:OpaquePointer?
if sqlite3_prepare_v2(BaseDatos, cadenasql, -1, &stmt, nil) == SQLITE_OK
{
As you can see, it is a simple query to a database table. Well this is where I ALWAYS get the problem. Cannot find any tables in the database. The database has 8 tables, and it doesn't find any of them. And it is something that I do not understand, if we have found the database and we have opened it (and it has not given me any error), why does it not find ANY TABLE inside the database?
Always the same message ---> No much: ( name of table).
And I don't understand, I don't understand, I don't understand...why?????????
It's maddening. I have searched for countless forums, documents, etc on the internet and I follow the steps of all of them and always always the same error. Before it couldn't find the database, it already does, but it can't find the tables. I'm going crazy. I don't understand how it can cause so much trouble. I have programmed in other languages and none have given me so many problems ( c, cobol, assembler, pascal, python, R, java)... I'm about to forget all my project, please, any help... some point of light in the face of so much despair. thank you !!
Topic:
Developer Tools & Services
SubTopic:
Xcode
Tags: