Search results
ConfigurationManager.ConnectionStrings - will read the connection string. var conn1 = ConfigurationManager.ConnectionStrings["conn1"].ConnectionString;
31 sty 2024 · Then, let’s use the GetConnectionString() method of the Configuration object to read our connection string from the settings file: IConfiguration configuration = builder.Build(); var connString = configuration.GetConnectionString("ProductsDb");
26 maj 2011 · Then you can use this Method that returns the connection string to be ready to passed to the sqlconnection object to continue your work as follows: private string ReturnConnectionString() { // Put the name the Sqlconnection from WebConfig.. return ConfigurationManager.ConnectionStrings["DBWebConfigString"].ConnectionString; }
Get connection string using ConnectionStrings property of ConfigurationManager class. string connectionString = ConfigurationManager.ConnectionStrings[" MyConnection "].ConnectionString; Where MyConnection is the name of the connection as specified in the config file.
A database connection string is a string that specifies information about how to connect to a particular database. In the context of Entity Framework Core (EF Core), a connection string provides the necessary details for the DbContext to establish a connection to the database.
22 gru 2021 · In this article we will learn about How to read connection string in .NET Core. In ASP.NET Core, configuration API provides a way of configuring an app based on a list of name-value pairs that can be read at runtime from multiple sources.
12 kwi 2020 · In this article we discuss how to read connection string dynamically in ASP .NET Core. Before starting this article please go through the link How to read connection string in ASP .NET Core. Earlier we fetch the connection string from appsettings.json file using Dependency Injection.