connection-string

What does <clear /> signify when specifying a connectionstring?

假如想象 提交于 2019-12-03 22:25:06
问题 This answer to another question states: Do not forget to clear the connectionStrings first: <connectionStrings> <clear /> <add name="LocalSqlServer" connectionString="Data Source=(local);Initial Catalog=aspnetdb;Integrated Security=True" providerName="System.Data.SqlClient"/> </connectionStrings> ... interesting. What does that do? 回答1: In .Net config files are inherited, so your applications config will inherit settings from your machines config. The <clear/> tag will remove any inherited

How to read connection string inside .NET Standard Class library project from ASP.NET Core

牧云@^-^@ 提交于 2019-12-03 21:49:18
In my solution, I have a ASP.NET Core web project and a .NET Standard class library project. Class library project is the data access layer and I want to read the connection string from my appsettings.json (ASP.NET Core project) in my data access layer. I have found few answers such as by Andrii Litvinov which looks like quite straight forward to implement but he also mentioned about implementing through Dependency Injection. I don't want to choose the easy shortcut way but looking for the dependency injection implementation? I am not sure if having appsettings.json in my class library and

ConnectionStrings in app.config. What about security?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-03 21:04:48
Is it really a Good Thing to put connection strings with passwords in the app.config file? It seems to me that the app.config is not encrypted in any way and the password information can be easily read. I have an app which accesses a database for which the intended end-user have no authentication. A group user/password is used. The application only starts if the current windows user is in an Active Directory group. So, once in the app, the user is allowed to connect to the DB using the group user. What would be the correct way to handle such connection strings? Hide them in the source code?

Is ConfigurationManage -> section.SectionInformation.ProtectSection() machine dependent?

让人想犯罪 __ 提交于 2019-12-03 20:07:26
问题 in the code Configuration config = ConfigurationManager.OpenExeConfiguration (Application.ExecutablePath); ConnectionStringsSection section = config.GetSection("connectionStrings") as ConnectionStringsSection; if (!section.SectionInformation.IsProtected) { section.SectionInformation.ProtectSection("DataProtectionConfigurationProvider"); } I´m getting some trouble when I move the application to another machine. is the section.SectionInformation.ProtectSection call machine dependent, meaning, I

Stop LINQ to SQL dbml from updating connection string when I drag tables into the dbml file

陌路散爱 提交于 2019-12-03 19:26:39
问题 Every time I drag a modified table into my dbml, VS2010 wants me to update the connection string even though I have created a data connection with the exact same information. Every time this happens it changes my connection string to 'DataSourceConnectionString' and I have to delete it from 5 different files and replace it with the name of the connection string I was using previously so it doesn't screw up everyone else using the file through source control. Any Ideas? 回答1: I figured out

How do I create a Solution Wide Connection String

拜拜、爱过 提交于 2019-12-03 16:12:24
Does anyone know if it is possible to create a single connection string that will be accessible to all the projects in a solution (we have about 6). I can create a text file with this information, but we need design time support as well, and it is not practical to have a connection string in every App.Config and Web.config file in the solution. We basically want a Single connection string that is easy to change should the location of the db change, that will also be used by the IDE for design time support mafu Not sure, can't you just put a new config file to the solution items and include and

To close or not to close an Oracle Connection?

我只是一个虾纸丫 提交于 2019-12-03 15:57:27
My application have performance issues, so i started to investigate this from the root: "The connection with the database". The best practices says: "Open a connection, use it and close is as soon as possible", but i dont know the overhead that this causes, so the question is: 1 -"Open, Use, Close connections as soon as possible is the best aproach using ODP.NET?" 2 - Is there a way and how to use connection pooling with ODP.NET? I thinking about to create a List to store some connections strings and create a logic to choose the "best" connection every time i need. Is this the best way to do

Sql connection waits 15 seconds despite 3 seconds timeout in connection string

﹥>﹥吖頭↗ 提交于 2019-12-03 14:24:44
I have a website using Microsoft SQL 2008 server over local network. Sometimes, SQL server machine is rebooted, and so the website fails to connect to the database. If the machine is up and running, it will respond fast. If it's down, there is no need to wait for 15 seconds. 3 seconds are ok. I want to display apologizes on the website when the database is not reachable, and want to do it fast. But setting Connection Timeout=3 in connection string seems having no effect. The page spends 22 seconds to wait before throwing SqlException on SqlConnection.Open(); . What's wrong with it? May it be a

How to configure database connection securely

为君一笑 提交于 2019-12-03 13:19:44
问题 Similar but not the same: How to securely store database connection details Securely connecting to database within a application Hi all, I have a C# WinForms application connecting to a database server. The database connection string, including a generic user/pass, is placed in a NHibernate configuration file, which lies in the same directory as the exe file. Now I have this issue: The user that runs the application should not get to know the username/password of the general database user

Calling a stored procedure with asp.net

放肆的年华 提交于 2019-12-03 13:15:23
If I have a connection string defined in my web.config file, how do I create a connection to the SQL db from C# code (sorry forgot to specify) and then call a stored procedure. I would then like to eventually use this data in some way as my DataSource for a GridView. Here is how the connection string is defined in the web.config: <connectionStrings> <add name="db.Name" connectionString="Data Source=db;Initial Catalog=dbCat;User ID=userId;Password=userPass;" providerName="System.Data.SqlClient" /> </connectionStrings> The db server is a Microsoft SQL server. Here is what I was looking for: