简体   繁体   中英

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

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?

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.

您需要引用旧版本的System.data.SqlServerCe.dll,然后才能访问数据库

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM