简体   繁体   English

C#将密码添加到DataSet连接,其中ConnectionRef指向App.Config连接字符串

[英]C# Add Password to DataSet connection where ConnectionRef points to App.Config connection string

I have a DataSet.xsd file that has a TableAdapter with a MainSource DbSource. 我有一个具有TableAdapter和MainSource DbSource的DataSet.xsd文件。 I want to override the connection string by adding a password in code (so as not to store the password in the App.Config file). 我想通过在代码中添加密码来覆盖连接字符串(以免将密码存储在App.Config文件中)。 The ConnectionRef points to a connection string in App.Config. ConnectionRef指向App.Config中的连接字符串。 How do I go about overriding that? 我如何去覆盖它? I still want the base connection string stored in App.Config, but I want to replace the specific reference to add the password. 我仍然希望将基本连接字符串存储在App.Config中,但是我想替换特定的引用来添加密码。

I found how to do it for the Entity framework, but I am not working with that, and even that response was rather unspecific as to where to put the code to override the behavior. 我找到了针对Entity框架的操作方法,但我并没有为此工作,即使该响应对于将代码放在何处以覆盖行为还是相当不确定的。

I was not able to figure out how to override the behavior. 我无法弄清楚如何覆盖此行为。 And, every time I make an update, Visual Studio overwrites my code, but I figured out that I can modify the system generated code in the DataSet.Designer.cs file. 而且,每次进行更新时,Visual Studio都会覆盖我的代码,但是我发现可以修改DataSet.Designer.cs文件中系统生成的代码。 It is not an ideal solution, but since I needed some solution, it was the best I could come up with. 这不是理想的解决方案,但是由于我需要一些解决方案,因此这是我能想到的最好的解决方案。 It answers my question for now. 它现在回答了我的问题。 Perhaps when I figure out how to word my question better, I can ask another one that may generate more responses. 也许当我想出如何更好地表达我的问题时,我可以问另一个可能产生更多答案的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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