Problem creating database table

Good night I created a project to create a Sqlite table in unity but it fails to query the table as if it did not exist.

I will put a piece of code where it creates the table and the error that appears

public class MyDBConnection : MonoBehaviour
{
    private IDbConnection connection;
    private IDbCommand command;
    private IDataReader reader;

    public string dbFile = "URI=File:MySQLiteDB.db";

    void Start()
    {
        Connection();
    }
    private void Connection() {
        connection = new SqliteConnection(dbFile);
        command = connection.CreateCommand();
        connection.Open();

        string testTable = "CREATE TABLE IF NOT EXISTS invetory(id INTEGER PRIMARY KEY AUTOINCREMENT, idItem INT, name VARCHAR(50), quantity INT);";

        command.CommandText = testTable;
        command.ExecuteNonQuery();
    }

    public void Insert() {

        string query = "INSERT INTO inventory(idItem, name, quantity) VALUES(2, 'potion', 1);" +
            "INSERT INTO inventory(idItem, name, quantity) VALUES(54, 'hi-potion', 1);" +
            "INSERT INTO inventory(idItem, name, quantity) VALUES(23, 'ex-potion', 1);" +
            "INSERT INTO inventory(idItem, name, quantity) VALUES(98, 'sword', 1);" +
            "INSERT INTO inventory(idItem, name, quantity) VALUES(5, 'bread', 1);";
        command.CommandText = query;
        command.ExecuteNonQuery();

    }

Check your spelling of ‘invetory’

1 Like