Saturday, February 25, 2006 5:44 PMHi,
I am trying to write a desktop application using C# and .NET that can edit an SQL Server Mobile database stored on a device. The problem is no matter how I specify the data source, I get an error the path was not found. Heres the bit of the code:
string strConn = "Data Source=" + "Mobile Device\\My Documents\\Nutricom.sdf";
SqlCeConnection connDB = new SqlCeConnection(strConn);
And the error i get is..
The path is not valid. Check the directory for the database. [ Path = Mobile Device\My Documents\Nutricom.sdf ]
Everytime it thorws an error saying the path is invalid and to check the locaiton of the database. Ive tried it without the "Mobile Device" bit of the string and still nothing. The database is definately in this location.
Any help? It's driving me insane.
Saturday, February 25, 2006 7:29 PM
You can not do that as remote SQL CE provider you have to use to accomplish that is undocumented and to be used by VS only.
Local provider you’re probably using is incapable of accessing database on device as device file system is not accessible from desktop using standard APIs.
Due to licensing restrictions you can use local desktop provider only if one of the following is true:
1. You have VS 2005 installed on this PC.
2. You have SQL Server 2005 installed on this PC.
3. Your PC is running Windows XP Tablet edition.
Assuming licensing conditions are met, you can copy data base from device using RAPI, open it with local provider, change it and copy it back to the device.
Saturday, February 25, 2006 7:34 PMHi,
Thank you for your reply.
I am using Visual Studio 2005. Just to clarify are you saying there is no way to access the database on the device WITHOUT coping it over using RAPI? or just that it is un-documented?
I have considered using RAPI and will look into it. However I have fears it may cause syncronisation issues so I would prefer to do it the first way if possible.
Saturday, February 25, 2006 9:08 PM
Using remote SQL Mobile provider is undocumented and probably would violate your license.
However, there's always a way (complexity on scale from 1 to 10):
1. Map device storage to desktop drive (8).
2. Make sure application which uses database is stopped on device while desktop is changing copy of the data base (1).
3. Add remote data access capabilities to your application (3).
4. Use 3rd party tools if available (1).
I'd go with #3 as it's simple enough and has no licensing issues.
Saturday, February 25, 2006 9:18 PMHi,
Thanks again for your kind reply.
I'm afraid one again I don't fully understand sorry . I am new to programming on the. Net platform.
Number 3 sounds good to me but I don't understand what you mean by "remote data access capabilities". Is there anywhere I can find further information on this?
For anyone else wanting to do something similar I found an excellent set of libraries from OpenNETCF.org that simplify the RAPI method of coping the database tot he device and back again. I'll use them if I can't get one of the methods above working.
Sunday, February 26, 2006 12:43 AM
Basically that means what somewhere in your code you need to listen on the TCP/IP port, accepting command and data from desktop and sending requested data back. It's not related to .Net platform, concept is known for 40 years or so. There are some 3rd part products like that:
Sunday, February 26, 2006 11:09 AM
Ah thank you very very much.
At least I understand my options now.
Thanks again for your patience and help.
Friday, May 05, 2006 9:13 PMI Still Have Problem
I receive This error message :
"The path is not valid. Check the directory for the database."
if any one solve this problem Tell me.
Monday, May 08, 2006 4:49 PM
I have developed some tools that may help you:
Tuesday, March 04, 2008 4:04 PM
What does it all mean?!?!!?!?!?!!?
We have an .sdf file that has been added to the root of the project, and it doesn't work when I either use
+ [my documents].Database.sdf
(didn't think it would, but thought maybe it was some kind of odd compact framework way of doing things)
+ connectionstring specified in the server explorer
what's the deal??? What am I doing wrong?