Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I am getting error when I am trying to open connection. My DB.sdf file is in my application folder
here i stored db.sdf
string ConnectionString= new System.IO.FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).DirectoryName + @"\APP_DATA\DB.sdf";
public int ExecuteNonQuery(string query){
int res = -1;
using (SqlCeConnection conn = new SqlCeConnection(ConnectionString))
SqlCeCommand command = new SqlCeCommand(query, conn);
command.CommandType = CommandType.Text;
conn.Open();
res = command.ExecuteNonQuery();
catch (Exception e)
new Logs().TraceProcessError(e.Message);
return res;
Error:
You are trying to access an older version of a SQL Server Compact
Edition database. If this is a SQL Server CE 1.0 or 2.0 database, run
upgrade.exe. If this is a SQL Server Compact Edition 3.0 or later
database, run Compact / Repair. [ Db version = 3505053,Requested
version = 3004180,File name = D:\DB.sdf ]"
and I am using SQL Server Compact 3.5., VS2010, SQLServer 2008R2.
please help.
thanks.
–
–
–
Can you please refer to the link below:
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/058357a2-e8a2-447e-82dc-df4466542855/trying-to-open-a-sql-compact-db-in-vb2005-created-it-in-vb2008?forum=sqlce
Hope it helps..!!
–
https://sqlcetoolbox.codeplex.com/
Run it against your data base file and note down the version number (eg. 3.5)
Go into visual studio click on System.Data.SqlServerCe under resources and then click under the properties. In properties note down the version number (eg. 3.0)
If the the library version number is older. Download the SQL Server Compact installer and run.
http://www.microsoft.com/en-IE/download/details.aspx?id=12264
Once installed. Delete the references to System.Data.SqlServerCe and System.Data.SqlClient from your project and add their equivalent 3.5 versions. Found on my system at.
C:\Program Files (x86)\Microsoft SQL Server Compact Edition\v3.5\Devices\System.Data.SqlServerCe.dll
C:\Program Files (x86)\Microsoft SQL Server Compact Edition\v3.5\Devices\Client\System.Data.SqlClient.dll
Clean and then rebuild. Like I mentioned in the comment, this undid itself at some point on VS 2008 so if you get the error again double check the path is going to the above.
Thanks for contributing an answer to Stack Overflow!
-
Please be sure to
answer the question
. Provide details and share your research!
But
avoid
…
-
Asking for help, clarification, or responding to other answers.
-
Making statements based on opinion; back them up with references or personal experience.
To learn more, see our
tips on writing great answers
.