在 Silverlight Business 应用程序中提取 web.config 中 ConnectionStrings 的内容

发布于 2024-10-08 18:11:49 字数 453 浏览 0 评论 0原文

我正在尝试从 Silverlight 业务项目的 web.config 中的 读取数据源广告目录。不幸的是,当我使用 SqlConnectionStringBuilder 时,我无法读取连接字符串

connectionString="metadata=res://*/MainDatabase.Main.csdl|res://*/MainDatabase.Main.ssdl|......."

,因为它

connectionString="Data Source=My-PC\SQL_2008;Initial Catalog =....

可以使用“Split”来获取它们,但是我不喜欢这个解决方案。有什么办法可以得到我的要求吗?

谢谢

I am trying to read dataSource ad Catalog from <connectionStrings> in web.config in Silverlight business project. Unfortunately when I used SqlConnectionStringBuilder, I could not read connection string the has

connectionString="metadata=res://*/MainDatabase.Main.csdl|res://*/MainDatabase.Main.ssdl|......."

where as it work for

connectionString="Data Source=My-PC\SQL_2008;Initial Catalog =....

I could get them using "Split" however, I don't like that solution. Is there any way to get my requirements?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

野稚 2024-10-15 18:11:49

您的第一个连接字符串(不起作用)是一个实体框架连接字符串 - 它不是 SqlConnectionStringBuilder 可以理解的格式。但是,EntityConnectionStringBuilder 会理解这一点,并且它有一个名为 ProviderConnectionString 的属性。该属性将包含实际的 SQL 连接字符串,您可以将其传递给 SqlConnectionStringBuilder (如第二个示例中所示)。

Your first connection string (that isn't working) is an Entity Framework connection string - it isn't in a format the SqlConnectionStringBuilder can understand. However, EntityConnectionStringBuilder will understand that, and it has a property called ProviderConnectionString. This property will have the actual SQL connection string in it, which you can pass to a SqlConnectionStringBuilder as in your second example.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文