Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to use password protected sqlite database?

How to use password protected sqlite database?

Scheduled Pinned Locked Moved C#
databasetutorialsqlitehelpquestion
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DPaul1994
    wrote on last edited by
    #1

    I have a sqlite database protected by password and I can't use it in query. How should I modify the code to read data from a protected database?

    private static string conn = @"Data Source=aplicatie.db;Pooling=true;FailIfMissing=false;Version=3;Password=example";

    An example with query:

    string selectutilizator = "SELECT username,prenume,licenta FROM accounts";
    SQLiteCommand selcom = new SQLiteCommand(selectutilizator, Conexiune.getConnection());
    selcom.CommandType = CommandType.Text;
    using (SQLiteDataReader read = selcom.ExecuteReader())
    {
    if (read.Read())
    {
    SimulatorManager.Nume = (string)read["username"];
    SimulatorManager.Prenume = (string)read["prenume"];
    SimulatorManager.Utilizator = SimulatorManager.Nume + " " + SimulatorManager.Prenume;
    }
    }

    Error is:

    file is encrypted or is not a database

    L OriginalGriffO 2 Replies Last reply
    0
    • D DPaul1994

      I have a sqlite database protected by password and I can't use it in query. How should I modify the code to read data from a protected database?

      private static string conn = @"Data Source=aplicatie.db;Pooling=true;FailIfMissing=false;Version=3;Password=example";

      An example with query:

      string selectutilizator = "SELECT username,prenume,licenta FROM accounts";
      SQLiteCommand selcom = new SQLiteCommand(selectutilizator, Conexiune.getConnection());
      selcom.CommandType = CommandType.Text;
      using (SQLiteDataReader read = selcom.ExecuteReader())
      {
      if (read.Read())
      {
      SimulatorManager.Nume = (string)read["username"];
      SimulatorManager.Prenume = (string)read["prenume"];
      SimulatorManager.Utilizator = SimulatorManager.Nume + " " + SimulatorManager.Prenume;
      }
      }

      Error is:

      file is encrypted or is not a database

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Are you sure that the password is correct?

      D 1 Reply Last reply
      0
      • D DPaul1994

        I have a sqlite database protected by password and I can't use it in query. How should I modify the code to read data from a protected database?

        private static string conn = @"Data Source=aplicatie.db;Pooling=true;FailIfMissing=false;Version=3;Password=example";

        An example with query:

        string selectutilizator = "SELECT username,prenume,licenta FROM accounts";
        SQLiteCommand selcom = new SQLiteCommand(selectutilizator, Conexiune.getConnection());
        selcom.CommandType = CommandType.Text;
        using (SQLiteDataReader read = selcom.ExecuteReader())
        {
        if (read.Read())
        {
        SimulatorManager.Nume = (string)read["username"];
        SimulatorManager.Prenume = (string)read["prenume"];
        SimulatorManager.Utilizator = SimulatorManager.Nume + " " + SimulatorManager.Prenume;
        }
        }

        Error is:

        file is encrypted or is not a database

        OriginalGriffO Offline
        OriginalGriffO Offline
        OriginalGriff
        wrote on last edited by
        #3

        As Richard says, the wrong password is the most obvious problem. Other possibilities are: 1) It's not an SqLite database at all - ".db" is a common enough extension that it could be a different application 2) It's SqLite, but from a different version - check that the DLLs you are using to access it are the latest version, and that you didn't create it in a later application. If in doubt, it's worth setting up a connection in Visual studio via the Server Explorer pane - if "Connect to Database" doesn't list SqLite then see here: http://stackoverflow.com/questions/19665370/missing-sqlite-data-provider-in-vs-2013[^] Once you have a working connection in VS, you can get a "good" connection string in the Properties Pane.

        Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
        "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

        1 Reply Last reply
        0
        • L Lost User

          Are you sure that the password is correct?

          D Offline
          D Offline
          DPaul1994
          wrote on last edited by
          #4

          My next stupid question is: How should I suppose to set a password for sqlite database? :)) Cause obviously I don't know how..I thought that I just have to set there a password..

          L 2 Replies Last reply
          0
          • D DPaul1994

            My next stupid question is: How should I suppose to set a password for sqlite database? :)) Cause obviously I don't know how..I thought that I just have to set there a password..

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Speaking for myself, I would start by reading the documentation.

            1 Reply Last reply
            0
            • D DPaul1994

              My next stupid question is: How should I suppose to set a password for sqlite database? :)) Cause obviously I don't know how..I thought that I just have to set there a password..

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              DPaul1994 wrote:

              How should I suppose to set a password for sqlite database?

              private static string conn = @"Data Source=aplicatie.db;Pooling=true;FailIfMissing=false;Version=3;Password=example";

              What happens if you connect using this to a non-existing file?

              Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups