connection-string

How to read connection string in .NET Core?

别等时光非礼了梦想. 提交于 2019-11-27 06:42:56
I want to read just a connection string from a configuration file and for this add a file with the name "appsettings.json" to my project and add this content on it: { "ConnectionStrings": { "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet- WebApplica71d622;Trusted_Connection=True;MultipleActiveResultSets=true" }, "Logging": { "IncludeScopes": false, "LogLevel": { "Default": "Debug", "System": "Information", "Microsoft": "Information" } } } On ASP.NET I used this: var temp=ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString; Now how can I read

Entity Framework: “ProviderName” in connection string required- all of the sudden?

故事扮演 提交于 2019-11-27 06:40:20
问题 We've been using Entity framework in a production environment for many months now, and just yesterday started to get errors on some machines when querying the database using our subclass of DbContext: "The connection string 'MyConnectionString' in the application's configuration file does not contain the required providerName attribute" Our problem is easily solved: I adding the "providerName="System.Data.SqlClient" to the connection string in the config files on all deployed servers and

Persist Security Info Property=true and Persist Security Info Property=false

三世轮回 提交于 2019-11-27 06:34:11
问题 For the properties: Persist Security Info=true and Persist Security Info=false Can you tell me what is the difference between them, and if I don't put it in my connection what will happen? connect.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=C:/Users/Nourah/Downloads /Phase3/Salary.accdb; Persist Security Info=False;"; 回答1: Even if you set Persist Security Info= true OR Persist Security Info=false it won't show a difference in front..The difference is happening at

Keyword not supported: “data source” initializing Entity Framework Context

不想你离开。 提交于 2019-11-27 06:30:54
I'm initializing Entity Framework Object context, and this gives me the keyword not supported error: metadata=res://*/MainDB.csdl|res://*/MainDB.ssdl|res://*/MainDB.msl;provider=System.Data.SqlClient;provider connection string="Data Source=.\SQLEXPRESS;AttachDbFilename=D:\Workspace\vs\Leftouch\Leftouch.Web\Data\Leftouch.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True;App=EntityFramework" I took the connection string directly from web.config which was working, and modified only the path to the file (which I set dynamically), and instead of using the default value, used this

How to use Application Data in an (App.config) connectionString

核能气质少年 提交于 2019-11-27 06:24:21
问题 I've got an SQL Server CE database in a project that I wan't to store somewhere in the %AppData% directory. However I can't find a way to make a reference to the Application Data path in the connection string (in the App.Config) <?xml version="1.0"?> <configuration> <configSections> </configSections> <connectionStrings> <add name="EntityConnectionString" connectionString="metadata=res://*/EntityModel.csdl|res://*/EntityModel.ssdl|res://*/EntityModel.msl;provider=System.Data.SqlServerCe.3.5

Azure connection string best practices

∥☆過路亽.° 提交于 2019-11-27 06:19:10
I have an application that I am just migrating to Azure. Currently I use web.config transformation to manage changing the database connecting string dev/staging/prod environments. How is it best to manage these multiple connection strings in Azure? Jonathan McIntire In cases where it doesn't matter if the developer can see production credentials, you can use the built-in Visual Studio 10 config transformations. If this is what you're looking for, follow these steps: 1.Navigate to your Azure project folder in file explorer 2. Make a copy of ServiceConfiguration.cscfg 3. Rename copy to

Connect to SQL Server Database from PowerShell

不羁岁月 提交于 2019-11-27 05:38:17
问题 I have looked around online for a while now and found many similar problems but for some reason I can't seem to get this working. I am just trying to connect to a SQL server database and output the query results to a file - See PowerShell script below. What I am uncertain about is how to integrate the User ID and Password into the connection string. $SQLServer = "aaaa.database.windows.net" $SQLDBName = "Database" $uid ="john" $pwd = "pwd123" $SqlQuery = "SELECT * from table;" $SqlConnection =

Possible to set default schema from connection string?

此生再无相见时 提交于 2019-11-27 05:23:35
With SQL Server 2005 and 2008 is it possible to set the default schema from the connection string? It'd be a lot easier if we didn't have to manually set the schema with SQL code. No, this is done at the database User level, not in the connection string. For reference, here are all of the properties which can be set in a connection string: http://www.connectionstrings.com/Articles/Show/all-sql-server-connection-string-keywords You set the default schema based on the user who is logging in via the connection, not the connection itself. ALTER USER Mary51 WITH DEFAULT_SCHEMA = Purchasing;

.Net Encryption

随声附和 提交于 2019-11-27 05:19:56
问题 What I would like to know is the definite approach to encrypting connection strings in a config file. Here are my questions: Using machine-level encryption, can't anybody accessing my server write a little .Net program to read the contents of the connection strings? If I am deploying my application to users machines in an enterprise environment, and the application has connection strings in a config file, how can I make sure only my application can decrypt it? The scenario is especially

How to fix error ::Format of the initialization string does not conform to specification starting at index 0::

瘦欲@ 提交于 2019-11-27 05:02:29
I uploaded my site on godaddy shared host. I can access this database from my management studio. I can't access this database from my site. I get following error: Format of the initialization string does not conform to specification starting at index 0. My connection string is in web.config and it looks like this: <connectionStrings> <add name="mcn" connectionString="Data Source=mydatabase.db.8706856.hostedresource.com; Initial Catalog=mydatabase; User ID=username; Password=xyz;" providerName="System.Data.SqlClient" /> </connectionStrings> What cause this error? I have also tried to write ..