ConnectionString to DB on Mobile Device: invalid path

Access DB on Mobile Device from .NET app on PC

Page 1 of 1

4 Replies - 11286 Views - Last Post: 30 August 2009 - 10:26 PM

#1 narins  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 11-August 09

ConnectionString to DB on Mobile Device: invalid path

Posted 11 August 2009 - 01:24 PM

I have a .NET Framework 3.5 Windows Forms application on my PC which needs to exchange data with a mobile device application (Windows Mobile 5.0) which is a .NET Compact Framework 3.5 application. The database on the handheld device is a SQL Server CE 3.5 database. I am using ActiveSync 4.5.

When I go to the Server Explorer in .NET Framework 3.5, right-click on Data Connections and select "Add connection" I can then choose the "ActiveSync connected device" as Data Source. Then in the Connection Properties I browse to my database (HHMethStdy.sdf file) which is in "Program Files\HandHeld08" directory on the actual mobile device. This works fine. When I look at the properties of this data connection I see the following:

Connection String: "Data Source=Mobile Device\Program Files\HandHeld08\HHMethStdy.sdf"
Provider: ".NET Framework Data Provider for Microsoft SQL Server Compact 3.5"
State: Open
Type: (nothing there)
Version: 3.5.0.0


I would like to connect to this very database programmatically from my .NET application on the PC. So I try the following:

public static void InitializeActualHHDBConn()
		{
			string DbActualHHConnectionString = "Data Source=\"Mobile Device\\Program Files\\HandHeld08\\HHMethStdy.sdf\"";
			dbActualHHConn = new SqlCeConnection(DbActualHHConnectionString);
			try
			{
				dbActualHHConn.Open();
			}
			catch (Exception e)
			{
				string str = "OpenDBConnection DB=ActualHHDB" + Util.ExtractExceptionMessages(e);
				throw (new Exception(str));
			}
		}



This results in the following error:
"The path is not valid. Check the directory for the database. [ Path = Mobile Device\Program Files\HandHeld08\HHMethStdy.sdf ]"


When I transfer the database to the PC and then provide the path as the connectionString I have no trouble connecting.

Any help on how to programmatically set the ConnectionString, or the information that this is not possible, would be greatly appreciated.

Thanks,

narins

Is This A Good Question/Topic? 0
  • +

Replies To: ConnectionString to DB on Mobile Device: invalid path

#2 Ikonmx  Icon User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • Posts: 45
  • Joined: 19-August 09

Re: ConnectionString to DB on Mobile Device: invalid path

Posted 24 August 2009 - 10:32 PM

I haven't use the active sync database. But I have used opennetcf to copy the database and process it. So the user doesn't need to copy the database.
Just after you copy the database be sure to compact the sql engine.

During the week will try to access the database via activesync will let you know of the results.
Was This Post Helpful? 0
  • +
  • -

#3 narins  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 11-August 09

Re: ConnectionString to DB on Mobile Device: invalid path

Posted 30 August 2009 - 07:48 PM

View PostIkonmx, on 24 Aug, 2009 - 09:32 PM, said:

I haven't use the active sync database. But I have used opennetcf to copy the database and process it. So the user doesn't need to copy the database.
Just after you copy the database be sure to compact the sql engine.

During the week will try to access the database via activesync will let you know of the results.

I submitted this reply by mistake. See next post.

This post has been edited by narins: 30 August 2009 - 07:57 PM

Was This Post Helpful? 0
  • +
  • -

#4 narins  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 11-August 09

Re: ConnectionString to DB on Mobile Device: invalid path

Posted 30 August 2009 - 07:54 PM

View PostIkonmx, on 24 Aug, 2009 - 09:32 PM, said:

I haven't use the active sync database. But I have used opennetcf to copy the database and process it. So the user doesn't need to copy the database.
Just after you copy the database be sure to compact the sql engine.

During the week will try to access the database via activesync will let you know of the results.


Thanks for your reply. That is what I am doing now - copying the database from the device to the PC, processing it locally and then copying it back to the mobile device. Except that I have not een compacting the database. Could you tell me why this would be important?
I would be very interested to learn what you find out.
Was This Post Helpful? 0
  • +
  • -

#5 Ikonmx  Icon User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • Posts: 45
  • Joined: 19-August 09

Re: ConnectionString to DB on Mobile Device: invalid path

Posted 30 August 2009 - 10:26 PM

I was compacting the database, because it keep saying the data was corrupted.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1