connection-string

App.config connection string relative path

无人久伴 提交于 2019-11-26 20:56:13
问题 I need to set in the app.config the sqlite connection string. I want to set the path relative to the debug/release folders the database file will be copied to those folders. <add name="EmailsSQLite" connectionString="data source=c:\Users\Test\Documents\Visual Studio 2008\Projects\TestConsole\Emails\data\EmailDatabase.sqlite" providerName="System.Data.SQLite"/> and I want to have something like: <add name="EmailsSQLite" connectionString="data source=\data\EmailDatabase.sqlite" providerName=

What is IMEX within OLEDB connection strings?

自闭症网瘾萝莉.ら 提交于 2019-11-26 20:34:53
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=localhost;Extended Properties=""Excel 8.0;HDR=Yes;IMEX=2" What is the purpose of IMEX=2 in the above connection string? Steve From ConnectionStrings "If you want to read the column headers into the result set (using HDR=NO even though there is a header) and the column data is numeric, use IMEX=1 to avoid crash. To always use IMEX=1 is a safer way to retrieve data for mixed data columns. .." Please note that the IMEX value can be very important when you need to write back data to the Excel. A fast search on Internet on IMEX found numerous articles

Help with a OleDB connection string for excel files

…衆ロ難τιáo~ 提交于 2019-11-26 20:26:40
The problem i'm having is that the data adapter is looking at only the first row in each column to determine the data type. In my case the first column "SKU" is numbers for the first 500 rows then I happen to have SKU's which are mixed numbers and letters. So what ends up happening is rows in the SKU column are left blank, but I still get the other information for each column row. I believe it is the connection string that controls that and with my current settings it should work, however it is not. Connection String: conn.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:

EF 5 Changing Connection String at Runtime

只愿长相守 提交于 2019-11-26 19:57:47
问题 Ok, I want to recreate a project that I created using EF 4.1 to EF 5.0, simple enough or at least I thought. One of the things in my old project is that I was able to change the database connection string at runtime in EF 4.1: using (var myContext = new MyEntities(ConnectionString)) { } Easy-peasy but in EF 5.0 you have to do this differently: string connectionString = "data source=LocalHost;initial catalog=MyDatabase;user id=MyUserName;password=MyPassword;multipleactiveresultsets=True;App

No connection string named 'MyApplicationEntities' could be found in the application config file

和自甴很熟 提交于 2019-11-26 19:56:12
问题 I just install EF 4.3 and trying to upgrade my project with migration. however I am getting issues with trying to execute add-migration initial to my project via Package Manager console. It is throwing any exception now No connection string named 'MyApplicationEntities' could be found in the application config file. Now my config has it all <connectionStrings> <add name="MyApplicationEntities" connectionString="metadata=res://*/DataModel.csdl|res://*/DataModel.ssdl|res://*/DataModel.msl

SQL Server Express connection string for Entity Framework Code First

♀尐吖头ヾ 提交于 2019-11-26 19:49:07
I am working in Visual Web Developer 2010 Express, and using the Entity Framework code-first CTP. I am able to do this with the new SQL Server CE but I am unable to find a connection string to work with SQL Server Express. This one, using the SQL Server CE beta, works fine (database is created and recreated on model changes). <add name="TrempimModel" connectionString="data source=|DataDirectory|TrempimModel.sdf" providerName="System.Data.SqlServerCe.4.0" /> This one, which I copied from the aspnetdb connections string, <add name="TrempimModel" connectionString="data source=.\SQLEXPRESS

Get ConnectionString from appsettings.json instead of being hardcoded in .NET Core 2.0 App

我只是一个虾纸丫 提交于 2019-11-26 19:27:40
问题 I have the following class in NET Core2.0 App. // required when local database does not exist or was deleted public class ToDoContextFactory : IDesignTimeDbContextFactory<AppContext> { public AppContext CreateDbContext(string[] args) { var builder = new DbContextOptionsBuilder<AppContext>(); builder.UseSqlServer("Server=localhost;Database=DbName;Trusted_Connection=True;MultipleActiveResultSets=true"); return new AppContext(builder.Options); } } This is required in Core 2.0 with migration when

How to configure ProviderManifestToken for EF Code First

前提是你 提交于 2019-11-26 18:57:39
I have a asp.net MVC3 project using EF code-first. For my unit testing I have been using SQL Server CE 4.0 and SQL Server 2008 Express. Both have worked perfectly with EF generating my database as expected. However, when I run my application outside of a unit test and point it at my connection strings I get the error ProviderIncompatibleException: The provider did not return a ProviderManifestToken string I have read the MS documentation on this and it appears this is a SqlVersion token that the EF model generates. The problem is that I am using the code first approach so I have no .edmx file

SQL Server Connection Strings - dot(“.”) or “(local)” or “(localdb)”

不问归期 提交于 2019-11-26 18:55:00
I've recently had to install SQL Server and restore a database to 2 laptops, the first took me a couple of days to figure out, the second I'm still struggling on. On both I was getting this error here: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) I'm still getting it on the second. I did a lot of

How to fix “The ConnectionString property has not been initialized”

社会主义新天地 提交于 2019-11-26 18:53:26
When I start my application I get: The ConnectionString property has not been initialized. Web.config: <connectionStrings> <add name="MyDB" connectionString="Data Source=localhost\sqlexpress;Initial Catalog=mydatabase;User Id=myuser;Password=mypassword;" /> </connectionStrings> The stack being: System.Data.SqlClient.SqlConnection.PermissionDemand() +4876643 System.Data.SqlClient.SqlConnectionFactory.PermissionDemand(DbConnection outerConnection) +20 System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +117 System.Data