在 Silverlight Business 应用程序中提取 web.config 中 ConnectionStrings 的内容
我正在尝试从 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的第一个连接字符串(不起作用)是一个实体框架连接字符串 - 它不是
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 calledProviderConnectionString
. This property will have the actual SQL connection string in it, which you can pass to aSqlConnectionStringBuilder
as in your second example.