My app is connected to a SQLite database and working fine. I want to create a 2nd table (“Users”) for login purposes. I tried to add that table to my existing database file, but get an error that there is already a table there. Can’t databases have multiple tables? How do I add a 2nd table to my database?
Are you adding the table in Xojo code or using an external tool ? Please provide a few screenshots and the exact error message.
but get an error that there is already a table there
Is there one already called Users?
Try creating a table called AppUsers instead
CREATE TABLE Users(
ID INT PRIMARY KEY NOT NULL,
Name TEXT NOT NULL,
PasswordHash TEXT NOT NULL,
...
);
No, my first table is named “test3”. Not even close.
Your string concatenation is definitely wrong. You do:
sql2 = sql + …
should be:
sql2 = sql2 + …
Alwaysbusy
You’re absolutely right!!
If you want to write a string over multiple lines then simply use +_
sql2 = "CREATE TABLE Users (" +_
"id integer, " +_
"firstname varchar, " +_
"username varchar, " +_
"password varchar, " +_
"PRIMARY KEY(id))"
1 Like