English 中文(简体)
为什么连接字符串的配置是只读的?
原标题:Why is the configuration of connectionstring readonly?

Sorry for the many asked question again, but i have not found a answer for solving my problem. First of all: I have a Web (customer-intranet, internal use only) where the user should decide, witch project should be shown. Every project has a connection to a database on different servers. So I have to change the connectionstring to the right database or I have to install the same web twice or more. I cannot use different connectstring-names, because the the dataset-designer stores the connectionname hardcoded in the c#-designer-code.

Is there really now way, to set the project-connectionstring maybe in the global.asax.cs? Or another way to handle this?

问题回答

也许您可以将设计器代码更改为不硬编码连接名称?

为什么不添加一个名为GetConnectionStringName()的方法,该方法由设计器调用,并将动态选择正确的连接字符串?

我只是编辑C#-designer代码,并将其替换为对配置管理器连接字符串引用的引用(或任何漂浮在船上的东西)。它是自动生成的,这并不意味着你不能编辑它。

@Hunter Not shure, what you mean. we create a Dataset-class in the App_Data-Folder with contextmenu Add->Class

@drachenstern I know, I could edit the designed code. That s not only me, who create webpages. And everytime something changed in the dataset-layout the code has to edit again. That s no option

@Nathan Taylor That s all in the designer-created code. I don t know, when the code is accessed and the connection will opened.





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签