Compact Framework 3.5 - 数据集运行时连接字符串
我发现了一篇 MS 文章,上面写着我可以使用 .XSD 文件的 ConnectionString 属性在运行时更改数据集的 ConnectionString。
这会在 .csproj 文件中设置一个名为“RuntimeConnectionString”的元素。
但是,当我将表适配器部署到 Motorola MC9190-G 设备 (Windows Mobile 6.5.1) 时,它不会更改表适配器的 ConnectionString。
我做错了什么,还是这是一个错误?使用 Compact Framework 更改运行时连接字符串的适当/替代选项是什么?
提前致谢
I found an MS article that says I can use the ConnectionString property of the .XSD file to change the DataSet's ConnectionString at run-time.
This sets an element in the .csproj file called "RuntimeConnectionString".
However, it doesn't change the tableadapters' ConnectionString when I deploy it to my Motorola MC9190-G device (Windows Mobile 6.5.1).
Am I doing something wrong, or is this a bug? What are the appropriate/alternate options to change the connection string for run-time with Compact Framework?
Thanks in Advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我花了一整天的时间寻找这个问题的解决方案。
看起来这是一个 Visual Studio 错误(我使用 VS2008Professional 并且也被困在这个问题上)。
在这种情况下,两种可能的操作是:
1)在构建TA之前(实际上在打开与数据库的连接之前)手动更改tableAdapter(TA)连接字符串。
2) 使用语句“|DataDirectory|” (不带引号)在您的助教的连接字符串中。在数据集设计器(架构)中选择 TA 并显示其属性。展开“连接”字段并选择不用于连接数据库的连接(VS2008 通常在将数据集绑定到 WinForms 控件时创建一个连接。如果没有,请手动为 TA 创建新连接)。因此,数据库连接的connectionString保持不变。
使用|数据目录|允许您使用数据库文件的相对路径,并且在大多数情况下与平台无关。对于我来说,这有帮助。希望,这也对您有帮助。
PS抱歉英语不好)
I spent a whole day in searching for solution to this problem.
Looks like it is a Visual Studio bug (I use VS2008Professional and had being stuck on this too).
Two possible actions in this case are:
1) Change the tableAdapter (TA) connectionString manually just before the TA had being constructed (before connection to db being opened in fact).
2) Use statement '|DataDirectory|' (without quotes) in connectionString for your TA. In dataSet designer (schema) select TA and show its properties. Expand 'Connection' field and choose connection that you NOT use to connect to database (VS2008 usually creates one when you binding dataSet to WinForms controls. Create new connection for TA manually, if not). Thus, connectionString for database connection remains unchanged.
Using |DataDirectory| allows you to use relative paths to your DB file and being a platform-independent in most cases. As for me, this helps. Hope, this helps you too.
P.S. Sorry for poor English)