开发者

Extracting contents of ConnectionStrings in web.config in Silverlight Business application

开发者 https://www.devze.com 2023-02-01 02:05 出处:网络
I am trying to read dataSource ad Catalog from <connectionStrings> in web.config in Silverlight business project. Unfortunatelywhen I used SqlConnectionStringBuilder, I could not read connection

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 s开发者_运维技巧tring 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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消