0

I'm getting this err msg:

enter image description here

...with this code:

        SqliteConnection conn = new SqliteConnection(connStr);
        String query = "INSERT INTO dbo.CartographerMain " +
                           "(MapName, MapNotes) " +
                           "VALUES (@MapName, @MapNotes)";

        using (SqliteCommand cmd = new SqliteCommand(query, conn))
        {
            cmd.Parameters.AddWithValue("@MapName", mapName);
            cmd.Parameters.AddWithValue("@MapNotes", mapNotes);
            await conn.OpenAsync();
            int result = await cmd.ExecuteNonQueryAsync();
            . . .   

My connStr path is:

Data source=C:\Users\bclay\source\repos\CartographerYou\CartographerYou\bin\x86\Debug\AppX\Cartographer.db

...and you can see that the database and table do exist in the expected location:

enter image description here

I'm also getting this warning message when compiling, which I don't understand, but which might be part of (or all of?) the problem:

enter image description here

B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862
  • 1
    Did you try `INSERT INTO CartographerMain` instead of `INSERT INTO dbo.CartographerMain` ? I've never used `dbo.` before my table name in Sqlite, and it always worked. – Leander Dec 19 '20 at 09:33
  • Thanks; removing the prepended "dbo." gets me a step further. Now I'm getting, "SQLite Error 8: attempt to write a readonly database" – B. Clay Shannon-B. Crow Raven Dec 20 '20 at 14:01
  • 1
    That could be a result of where you have your database stored. UWP has very strict file access. I place my databases in `ApplicationData.Current.LocalFolder`, but if you have very big databases you need to find something around this. GL – Leander Dec 20 '20 at 14:06
  • How do I get it to that location (ApplicationData.Current.LocalFolder)? My new question about the readonly problem, which shows where the file is currently located, is here: https://stackoverflow.com/questions/65380842/why-is-my-sqlite-database-considered-readonly – B. Clay Shannon-B. Crow Raven Dec 20 '20 at 14:17

0 Answers0