简体   繁体   中英

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

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM