Hi
I am developing a Smart Device App that will talk to a SSCE 2005 DB, but i am having some problems with the DB engine and communicating with it. I have the same problme on the device it's self and on the emulator.
If i copy a sdf file that i have crated using SQL Server Mangment studio on to the device the SQLCE App will not talk to it and i get the following error
The Database file cannot be found Check the path to the database [,,,File name,,]
Native error :25046
I get the same error if i connect it with code.
If i create the DB on the Device SQLCE reads it fine but i get the same error message when i try to get the app to connect to it.
also if i move a SDF file that i have created on the Device SQLCE gives me the error message.
What Am i doing wrong

Mobile SQL Issue
Gustavo Hernandez Minetti
I now have code in my vb.net 2003 App that creates the SDF file for me. this works fine and the file appears in the same folder as the exe file.
but when i try to connect to that file i get the error that tells me it is not there
this is the code that i used
Friend Sub CreateDB(ByVal strPath as string)
Dim newDB as SqlCeEngine
newDB = new SqlCeEngine
NewDB.LocalConnectionString = "DataSource = " & GetPath & "\Test.sdf;"
ConnectToDB("Data Source = " & StrPath " Test.sdf")
dim cmd as SqlCeCommand
cmd.CommandText = "Creat Table Numbers (AutoID int,Name Nvarchar(50))"
cmd.executenoneQuery()
end sub
Freind Sub ConnectToDB (strConnection as string)
try
db = new SqlCeConnecton(strConnection)
db.open()
catch ex as SqlCeException
msgbox err.message
end try
end sub
WV John
If it’s SQL CE 2.0 you can’t create databases for it on desktop, it's only supported starting SQL Mobile/Visual Studio 2005.
ramyaVijay
Are you using SQL CE 2.0 or SQL Mobile (AKA SQL CE 3.0) on device You can only create SQL Mobile DB on desktop which can be accessed using SQL Mobile on device. SQL CE 2.0 can not open SQL Mobile database.
Craig G
There's really only one way to create database for SQL CE 2.0/NETCF V1 (there’s no NETCF 1.1) - by using engine class. Once created, engine must be disposed off, after that you can open the DB. Yes, that code should work.
I would suggest printing out errors from error collection. Also try running your code without using engine, it should be only used once anyway.
DarkProphet
it did not work.
i have now added a newdb.dispose after the create command but i still get the same problem.
with Visual studio 2003 .net 1.1 should that code work
it creates the DB fine but still will not connect to it.
alienated
Why do you have this code Since database is already created engine is not needed. Also keep in mind SQL CE 2.0 only allows one connection to DB.
Dim newDB as SqlCeEngine
newDB = new SqlCeEngine
NewDB.LocalConnectionString = "DataSource = " & GetPath & "\Test.sdf;"
magja
the path that i have connected to is \My Documents\test.sdf.
the code being
ceConnection = new SqlCEConnection("Data Source =\My Documents\test.sdf";)
there is no password.
i also tried putting the DB file in the same folder as the exe file and adding code to find the path of the exe. All ways the same result.
should it be possible to create a database in SQL Server Managment Studio then copy the sdf file on to a PDA and access it with SQLCE
PrashG
I all happens in a side routine now that run once the first time i run the application.
141695
as for the Studio that i used to set it up i am not sure, it says
product version 3.0.5207.0
CLR Verson 2.0.50727.42.
NickNotYet
Most likely you’re specifying incorrect path to the database file. You should keep in mind devices don't have drive letters, don't have relative paths (which means you have to provide full path) and can't see your desktop's hard drive