connection-string

C# - Get file path from connection string

ε祈祈猫儿з 提交于 2020-01-21 07:36:22
问题 Is there an existing method in C# to extract the file path from a string that represents a ConnectionString to a SqlCE .sdf file? I want to check if the file exists at initialization and back it up if the file has been modified. Sample connection string: strConn = "Data Source=|DataDirectory|\dbAlias.sdf"; 回答1: A bit late perhaps, but I came across this question wile struggling with the same problem. You can find the location of the |DataDirectory| folder with AppDomain.CurrentDomain.GetData(

ASP.NET ConnectionString AttachDbFilename=|DataDirectory|

∥☆過路亽.° 提交于 2020-01-21 05:00:27
问题 This is about ConnectionStrings / ASP.NET MVC with Visual Studio 2012 ultimate & SQL Server Express 2012. Following up with this tutorial here: http://www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/intro-to-aspnet-mvc-4 I came across an issue with these two connection strings at my web.config: <connectionStrings> <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0; Initial Catalog=aspnet-MvcMovie-users; Integrated Security=SSPI; AttachDBFilename=

With System.Data.SQLite how do you specify a database file in the connect string using a relative path

旧街凉风 提交于 2020-01-19 11:21:05
问题 Wanting to deploy my project on different servers I would prefer to be able to specify a connect string using a relative path. I can't seem to get that to work and want to know if there is some trick to it...? 回答1: A suggestion You could build the absolute path in the app and pass that in the connection string. So, if you know that the database file is in the database subfolder of the application folder, you could do something like this (C#): string relativePath = @"database\myfile.s3db";

With System.Data.SQLite how do you specify a database file in the connect string using a relative path

送分小仙女□ 提交于 2020-01-19 11:14:58
问题 Wanting to deploy my project on different servers I would prefer to be able to specify a connect string using a relative path. I can't seem to get that to work and want to know if there is some trick to it...? 回答1: A suggestion You could build the absolute path in the app and pass that in the connection string. So, if you know that the database file is in the database subfolder of the application folder, you could do something like this (C#): string relativePath = @"database\myfile.s3db";

With System.Data.SQLite how do you specify a database file in the connect string using a relative path

我是研究僧i 提交于 2020-01-19 11:13:11
问题 Wanting to deploy my project on different servers I would prefer to be able to specify a connect string using a relative path. I can't seem to get that to work and want to know if there is some trick to it...? 回答1: A suggestion You could build the absolute path in the app and pass that in the connection string. So, if you know that the database file is in the database subfolder of the application folder, you could do something like this (C#): string relativePath = @"database\myfile.s3db";

How to read connection string in .NET Core?

牧云@^-^@ 提交于 2020-01-17 18:24:32
问题 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

C# and SQL Server CE - Data Source Keyword Not Supported

不羁岁月 提交于 2020-01-17 04:24:23
问题 I am trying the following solution and not having much luck: How can i update app.config connectionstring Datasource value in C#? The code I have is: Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); // Because it's an EF connection string it's not a normal connection string // so we pull it into the EntityConnectionStringBuilder instead EntityConnectionStringBuilder efb = new EntityConnectionStringBuilder( config.ConnectionStrings

iis7 pulling wrong connection string - cross site and process?

妖精的绣舞 提交于 2020-01-16 19:48:10
问题 I have two websites running on the same Windows 2008r2 64bit server, SQL Server Web edition. Both sites are identical with just the connection string pulling the data from a different database. Both sites are running in different application pools - both .net 2, classic pipeline, 32bit - and the website is quite old being developed back in 2005. Most of the data access is in compiled dll's in the bin directory. If I print out the connection string I'm using by calling ConfigurationManager

iis7 pulling wrong connection string - cross site and process?

坚强是说给别人听的谎言 提交于 2020-01-16 19:48:07
问题 I have two websites running on the same Windows 2008r2 64bit server, SQL Server Web edition. Both sites are identical with just the connection string pulling the data from a different database. Both sites are running in different application pools - both .net 2, classic pipeline, 32bit - and the website is quite old being developed back in 2005. Most of the data access is in compiled dll's in the bin directory. If I print out the connection string I'm using by calling ConfigurationManager

ConnectionString for connecting 3 master nodes to MySQL

安稳与你 提交于 2020-01-16 18:51:43
问题 Backgroud I am developing a .net project, which works with EF6 and MySQL DB. For High Availability, I am using Galera cluster, so I have 3 MySQL Master nodes up and running: master1 , master2 and master3 . According to connectionstring.com I should be able to use the following connection string: Server=master1, master2, master3;Database=myDataBase; Uid=myUsername;Pwd=myPassword; I have tried the above, and it does not work... I have seen this bug which explains multi-host connection string