Tuesday, March 27, 2012

Accessing from desktop - path not found.

Hi,
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);

connDB.Open();

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.

Lewis

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.

|||Hi,

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.
|||

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.

|||Hi,
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.

Lewis
|||

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:

http://www.gui-innovations.com/html/remotesqlce.html

|||

Ah thank you very very much.

At least I understand my options now.

Thanks again for your patience and help.

Lewis

|||I 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.

Thank You
mahyar
|||

I have developed some tools that may help you:

http://www.primeworks-mobile.com

No comments:

Post a Comment