如何从桌面应用程序连接到移动设备上的 SDF?
Mobile 6.1 设备上的 C# WinForms .Net 3.5 到 SQL CE 3.5
我想在通过 ActiveSync 连接时,在我的 Windows Mobile 设备上建立从桌面应用程序到 SDF 数据库的连接。 Visual Studio 允许我创建到我的设备的数据连接。连接测试正常,我可以使用 Visual Studio 查看数据库中的数据。
然后我创建一个表单并尝试填充 DataGridView。当我运行该程序时,我收到一条错误消息,指出数据库的路径无效。
我应该如何在连接字符串中指定移动设备路径?
在我的 App.Config 中,我尝试了路径的变体,但它们都不起作用:
connectionString="Data Source=Mobile Device\Program Files\SqlCeViaActiveSync\Orders.sdf"
connectionString="Data Source=\Mobile Device\Program Files\SqlCeViaActiveSync\Orders.sdf"
connectionString="Data Source=Program Files\SqlCeViaActiveSync\Orders.sdf"
connectionString="Data Source=\Program Files\SqlCeViaActiveSync\Orders.sdf"
完整的连接字符串部分如下所示:
<connectionStrings>
<add name="SqlCeViaActiveSync.Properties.Settings.OrdersConnectionString"
connectionString="Data Source=Mobile Device\Program Files\SqlCeViaActiveSync\Orders.sdf"
providerName="Microsoft.SqlServerCe.Client.3.5" />
</connectionStrings>
另外,我确实引用了 Microsoft.SqlServerCe.Client,因为我发现了几篇文章那提到这是必要的。
谁能指出我最近的一些文章/样本或让我知道我做错了什么?
谢谢!
C# WinForms .Net 3.5 to SQL CE 3.5 on Mobile 6.1 Device
I'd like to make a connection from a desktop application to a SDF database on my Windows Mobile device while it's connected via ActiveSync. Visual Studio lets me create a Data Connection to my device. The connections tests OK and I can view the data in the database using Visual Studio.
I then create a form and try to fill a DataGridView. When I run the program I get an error that the path to the data base is not valid.
How am I supposed to specify the Mobile device path in the connection string?
In my App.Config, I've tried variations on the path, but none of them work:
connectionString="Data Source=Mobile Device\Program Files\SqlCeViaActiveSync\Orders.sdf"
connectionString="Data Source=\Mobile Device\Program Files\SqlCeViaActiveSync\Orders.sdf"
connectionString="Data Source=Program Files\SqlCeViaActiveSync\Orders.sdf"
connectionString="Data Source=\Program Files\SqlCeViaActiveSync\Orders.sdf"
The full connection string section looks like this:
<connectionStrings>
<add name="SqlCeViaActiveSync.Properties.Settings.OrdersConnectionString"
connectionString="Data Source=Mobile Device\Program Files\SqlCeViaActiveSync\Orders.sdf"
providerName="Microsoft.SqlServerCe.Client.3.5" />
</connectionStrings>
Also, I did make a reference to Microsoft.SqlServerCe.Client, as I found a few articles that mentioned it was necessary.
Can anyone point me to some recent articles/samples or let me know what I'm doing wrong?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我刚刚发现以下内容有效:
这并不完全是我正在寻找的内容,但适用于此应用程序。
I just found that the following works:
It wasn't exactly what I was looking for but will work for this application.