Connect Pervasive DB with OLE DB

We have an existing closed source third party application using the Pervasive PSQL database. For example, PSQLs are located in the c: \ test directory and have names like holiday.dat, offers.dat, etc. I want to read and, if possible, write to these files without installing Pervasive Workstation Engine. With the Workstation Engine and ODBC connection, it works without any problem. But we will not install the Workstation Engine on any client, nor will the third party application.

In connectionsstrings.com I found the connection string:

"Provider=PervasiveOLEDB;Data Source=C:\datafilesDirectory;"

      

using directives:

using Pervasive.Data.SqlClient;
using System.Data.OleDb;
using System.Xml.Serialization;

snippet of test connection:

string strAccessConn = "Provider = PervasiveOLEDB; Data Source = C: \ datafilesDirectory;"

string strAccessSelect = "SELECT * FROM holidays";

// Create the dataset and add the Categories table to it:
DataSet myDataSet = new DataSet ();
OleDbConnection myAccessConn = null;

try
{
    myAccessConn = new OleDbConnection (strAccessConn);
}
catch (Exception ex)
{
    Console.WriteLine ("Error: Failed to create a database connection. \ N {0}", ex.Message);
    return;
}

try
{
    OleDbCommand myAccessCommand = new OleDbCommand (strAccessSelect, myAccessConn);
    OleDbDataAdapter myDataAdapter = new OleDbDataAdapter (myAccessCommand);

    myAccessConn.Open ();
    myDataAdapter.Fill (myDataSet, "Categories");
}
catch (Exception ex)
{
    Console.WriteLine ("Error: Failed to retrieve the required data from the DataBase. \ N {0}", ex.Message);
    return;
}
finally
{
    myAccessConn.Close ();
}

The application cannot open a connection to the database.

+2


source to share


1 answer


In the connection string, you must replace C: \ datafilesDirectory; with C: \ test ;.



+1


source







All Articles