ASP.NET connection string metadata syntax

自古美人都是妖i 提交于 2019-12-19 05:21:18

问题


I'm new to ASP.NET-ville, be gentle.

I have been troubleshooting a ASP.NET setup, where the server/database values are changing, therefore web.config needs to be updated.

There are multiple <add name="NameXYZ" connectionString="blah" /> instances (multiple ASP.NET components), but some of these are marked up differently to others.

I've got the following provided:

<add name="CONNECTION-B" connectionString="metadata=res://*/ZZZZ.ssdl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=XXX;Initial Catalog=YYY;Persist Security Info=True;User ID=AAA;Password=BBBB;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />


<add name="CONNECTION-A" connectionString="server=XXX;database=YYY;user id=XXX;password=BBB" />

I've used substituted values in the above, making the assumption that for both format types:

  • XXX is the server (MSSQL host)
  • YYY is the database name
  • AAA is the database user, and
  • BBB is the user password.

(ZZZZ is a pipe-delimited list of something)

Questions are as follows:

A) Is my assumption of synonymous connection string terms accurate? (Data Source <=> server, database <=> initial catalog)

B) Are there any syntax errors in the markup? Some MSDN documents I've looked up use double, single, and &quot; marks interchangeably.


回答1:


There are two different types of connection strings here. The best bet (IMO) is to have a read up in the docs -

The first is an ADO.Net connection string: http://msdn.microsoft.com/en-us/library/ms254500.aspx

The second is an Entity Framework connection string: http://msdn.microsoft.com/en-us/library/cc716756.aspx

It's all explained in those two links, certainly clearer than I can explain it!




回答2:


A great source of connection string information can be found here:

http://www.connectionstrings.com/




回答3:


I felt the need to post this since i also had some problems with this and later on discovered that there's a difference in connection string requirements for codefirst/model/database approaches:

MS Blog post about configuration settings for entitiy framework connection strings



来源:https://stackoverflow.com/questions/6148839/asp-net-connection-string-metadata-syntax

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!