Connect to an older version of SQL Server Compact database without upgrading

1.1k Views Asked by At

I am using VS2013 to connect to a .sdf database file and am getting this error:

The database file has been created by an earlier version of SQL Server Compact. Please upgrade using SqlCeEngine.Upgrade() method.

Here is my code:

string connectionstring = @"Data Source='E:\database.sdf'";
SqlCeConnection connection = new SqlCeConnection(connectionstring);
SqlCeCommand command = new SqlCeCommand("SELECT * FROM Colour", connection);
SqlCeDataAdapter dataAdapter = new SqlCeDataAdapter(command);
DataSet ds = new DataSet();
dataAdapter.Fill(ds);

I do not wish to upgrade the database (it is a production database). How can I retrive values from the database without upgrading the database?

2

There are 2 best solutions below

0
On

Have you tried manually saving your results as a csv file and use VS to read the csv file? If you can read your database server using SQL server then you can also try sqlcmd to query the database and grab the information out as a csv file. After that VS can read the file.

0
On

You need to reference an older version of System.data.SqlServerCe.dll, then you can access the database