Search code examples
c#.netdatabaseparadox

read a .db file in C#


 string Path = @"c:\Database\Mydatabase.db";

     string myConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Path + ";Extended Properties=Paradox 5.x;";

    // Define the database query    
    string mySelectQuery = "SELECT id,name FROM people WHERE id < 3;";

    // Create a database connection object using the connection string    
    OleDbConnection myConnection = new OleDbConnection(myConnectionString);

    // Create a database command on the connection using query    
    OleDbCommand myCommand = new OleDbCommand(mySelectQuery, myConnection);

    // Open the connection    
    myCommand.Connection.Open();

    // Create a database reader    
    OleDbDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);

The Error is at myCommand.Connection.Open(); and it says: 'c:\Database\Mydatabase.db' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.

I am trying to read a .db file in C#. However, I am getting an error, I am sure that file is located there, the error does not make sense for me. Could you please help me ? Or How can I read a .db(paradox) database file in C# ?

EDIT: string Path = @"c:\Database\";

The Error for this case is "The Microsoft Jet database engine could not find the object 'people'. Make sure the object exists and that you spell its name and the path name correctly."

If I change it like that, How can C# find which database file is gonna be used ? Since, I did not specify file name which is "Mydatabase.db" at anywhere

enter image description here


Solution

  • Confirmed it is an SQLite database, I just downloaded it on my phone and viewed it with an SQLite viewer.


    You will need to download an ADO.NET provider for SQLite:

    "Official" version (from SQLite, not MS)

    http://system.data.sqlite.org/index.html/doc/trunk/www/index.wiki

    Older version

    http://sqlite.phxsoftware.com/