All Questions
Tagged with connection-string .net
427
questions
273
votes
13
answers
462k
views
Read connection string from web.config
How can I read a connection string from a web.config file into a public class contained within a class library?
I've tried:
WebConfigurationManager
ConfigurationManager
But these classes are not ...
212
votes
5
answers
687k
views
Connection string using Windows Authentication
I am creating a website, but in the database I use windows authentication.
I know that you use this for SQL authentication
<connectionStrings>
<add name="NorthwindContex"
...
64
votes
9
answers
67k
views
How do I set a connection string config programmatically in .net?
I'd like to set a connection string programmatically, with absolutely no change to any config files / registry keys.
I have this piece of code, but unfortunately it throws an exception with "the ...
61
votes
2
answers
46k
views
connectionStrings configSource in App.config not working
I'm trying to separate my connection string from my App.config, and as you can't do transformations like with Web.config, I thought may I could use the configSource attribute to point to another ...
57
votes
4
answers
106k
views
Quick ways to test OLE DB Connection String
For debugging purpose I'd like to know ways to test OLE DB connection string quickly.
I've found this free software, it works on my machine, tested successfully.
Is there a even quicker way to do so,...
29
votes
3
answers
29k
views
SQLite EF6 programmatically set connection string at runtime
I try to migrate form EF 3.5 to 6 (with SQLite as database). We can not set the connection string in the app config file (this works without problems with ef6). We have to set connection string ...
29
votes
5
answers
20k
views
SQL integrated security using computer name instead of user name
I am trying to an SQL Express instance on the same network, authenticating with my domain user. It works just fine with Windows Authentication in SSMS. I verified that I can use the MyDB database, ...
28
votes
13
answers
16k
views
Connection string hell in .NET / LINQ-SQL / ASP.NET
I have a web application that comprises the following:
A web project (with a web.config file containing a connection string - but no data access code in the web project)
A data access project that ...
26
votes
7
answers
147k
views
Connection string - Keyword not supported: 'initial catalog'
I am using Webmatrix.data's Database entity to create a database connection, however it doesnt like my connection string. I am running it from MVC ASP.net.
Ive tried changing it to server / database,...
26
votes
4
answers
30k
views
Encrypting connectionStrings section - utility for app.config
Is there a utility that will encrypt a named configuration section (or just the connectionStrings section) in an app.config file in a similar manner that one can use aspnet_regiis with web.config ...
23
votes
4
answers
39k
views
C# Retrieving correct DbConnection object by connection string
I have a connection string being passed to a function, and I need to create a DbConnection based object (i.e. SQLConnection, OracleConnection, OLEDbConnection etc) based on this string.
Is there any ...
22
votes
2
answers
12k
views
What is the correct format for Running Entity Framework migrate.exe tool without a Web/App.config?
We recently switched to Entity Framework data migrations and I am working on some build automation scripts for our MVC app. I can successfully run the migrations from our build server using the ...
21
votes
4
answers
5k
views
.Net Encryption
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 ...
21
votes
2
answers
7k
views
Encrypt and deploy app.config
I read and tested a lot to find the best practice to encrypt and deploy an app.config to different machines. In general, I would like to secure the content of the connection string from third parties ...
19
votes
3
answers
50k
views
App.config connection string relative path
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="...
19
votes
2
answers
18k
views
Encrypting the connection string in web.config file in C#
I have written the name of my database, username and password in my web.config file as connection string.
I want to encrypt this data. How can I do it?
<connectionStrings>
<add name="...
19
votes
4
answers
9k
views
Best practices re sharing IDbConnection or connection string/factory in your .Net code
I'm wondering what would be the best prectice regarding mainataining connections to the database in .Net application (ADO.NET but I guess the practice should be the same for any data layer). Should I ...
19
votes
4
answers
15k
views
User Secrets in .NET 4.7 connectionstrings format
I have been digging for hours and keep coming up with information about .NET Core, yet hardly anything about .NET 4.7 full framework. I figured out how to add User Secrets to the main project of my ...
18
votes
1
answer
9k
views
Wait! which config file? (Entity Framework Connection String)
So, I created my entity model in a separate class library. I had to add the connection string to the app.config file of that class library. Then I added a ref for that project in my web application. I ...
17
votes
8
answers
16k
views
What is the best way to store connection string in .NET DLLs?
The application my team is currently developing has a DLL that is used to perform all database access. The application can not use a trusted connection because the database is behind a firewall and ...
16
votes
5
answers
13k
views
Is there a need to secure connection string in web.config?
So I am using connection strings in my web.config using SQL authentication.
Of course people say this could be a vulnerability as you are storing password in plaintext.
However, from what I know, ...
15
votes
1
answer
21k
views
Force the TCP/IP protocol in connection string
I have a database driven website written in asp.net. I'd like to modify the connection string to force protocol TCP. Please advise.
<add name="TESTConnectionString"
connectionString=...
15
votes
2
answers
27k
views
Entity Framework: "ProviderName" in connection string required- all of the sudden?
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:
...
14
votes
2
answers
77k
views
Oracle connection string without tnsnames.ora file
I am using the .NET framework with the System.Data.OracleClient namespace. I have the oracle 11 client installed on my computer. I do not want to use the tnsnames.ora file to store connection ...
14
votes
1
answer
9k
views
Multipleactiveresultsets in Entity Framework 4.1 Code First
This is my first EF project so bear with me please.
When updating an entity such as Department, you pull it from the context, update its values and call context.SaveChanges. However, if you update ...
14
votes
2
answers
7k
views
How to get provider specific ConnectionString from Entity Framework
using ado.net tipically we need to define a connectionstring to create a sqlconnection object, and if we use the entity framework, we have to dedine a connectionstring too.
is threre any way to get ...
14
votes
8
answers
40k
views
error occurred while establishing a connection to SQL Server
If I have my connection string in the web.config like this (added line feeds for better readability):
<add
name="conn"
connectionString="Data Source=(localdb)\v11.0; Initial
Catalog=MyDB; ...
14
votes
4
answers
2k
views
How is everyone storing connectionstrings?
I was wondering if people could post their solution to the ongoing problem of local databases and different connectionstrings among many developers in one project within source control?
More ...
13
votes
2
answers
2k
views
Where does this permanent SQLExpress connectionstring come from (not web.config)?
Today I noticed that in my ConfigurationManager.ConnectionStrings the very first instance is .\SQLEXPRESS. I remembered explicitly removing this entry from my web.config so I checked again, but didn't ...
13
votes
7
answers
34k
views
How to connect to mysql from C# over SSH
How can I connect to a mysql database trough C#,
This is my connection string now:
connectionString="server=localhost;port=3306;user id=root;Password=*****;database=Data" providerName="MySql.Data....
13
votes
4
answers
10k
views
winforms connection properties dialog for configuration string
Is there a way to display the connection properties dialog for connection string browsing(for database) in run time?
As I want the user to be able to connect to various database using the GUI.
The ...
12
votes
5
answers
16k
views
Overriding code-generated DbContext constructor
I'm sure I've done this before at some stage, but I can't figure out how to now! My scenario:
// This is generated from EDMX
public partial class HOLDbEntities : DbContext
{
public HOLDbEntities()...
12
votes
1
answer
7k
views
APP vs Application Name in Connection String
What's the differences between the APP attribute and Application Name attributes in the connection string? Is one just an alias to another one? I can't seem to find any documentations about it.
Also, ...
12
votes
4
answers
27k
views
Error occurred during the pre-login handshake
Please read in the entirety before marking this as duplicate.
In a project that I am debugging I receive a SqlException saying the following:
Additional information: A connection was successfully ...
11
votes
4
answers
14k
views
ConnectionStrings in app.config with characters that the .config file doesn't like
I've looked for the answer and can't find it. It's got to be something obvious and I'm just missing it.
We have a connection string issue in an app.config file. It uses SQL Server authentication, ...
11
votes
5
answers
14k
views
How to Access a connectionstring from another project
I got two project in my solution in Visual Studio 2010.
Project 1 contains an app.config with a ConnectionString.
How can I access that ConnectionString from Project 2?
Since they are both using the ...
10
votes
4
answers
42k
views
.Net PostgreSQL Connection String
I am using PostgreSQL in a project I am working on, and one of the queries is timing out. I need to increase the timeout on the database connection, but since I am using my DAO through a complex ...
10
votes
4
answers
53k
views
How to connect to Oracle DB from .NET?
When I open SQL Command Line, I write CONNECT username/password@[//]host[:port][/service_name] and it connects me to the database just fine. However, I'm unable to connect from a .NET project using a ...
10
votes
1
answer
20k
views
How to read a connectionstring in .net 4.5
How do I read a value from the web.config file for a connectionstring in the 4.5 .net framework?
I'm using system.configuration which I have a reference to and a using statement, but the only thing ...
10
votes
2
answers
36k
views
What does "pooling=false" in a MySQL connection string mean? [closed]
What does pooling=false in a .NET connection-string for a MySQL database mean?
This is the complete connection string:
return new MySqlConnection("SERVER=localhost;DATABASE=myDataBase;USER=###;...
10
votes
3
answers
1k
views
Can't connect to SQL LocalDB from Windows Service, WPF app & SSMS work fine?
Having some trouble with a system I'm developing. The layout as far as this question is concerned is a WiX built msi installer which installs SQL LocalDB 2012, a WPF app, and a Windows Service. Both ...
9
votes
3
answers
23k
views
C# connection string in web.config file
In my code behind page, how do I access the connection string which is stored in my web.config file?
9
votes
2
answers
26k
views
How to securely store a connection string in a WinForms application?
I need to know what is the common way to store a SQL server connection string for a WinForms application in VB.NET.
I have searched the net and I found answers to each of the following questions:
...
9
votes
5
answers
5k
views
NLog with an Entity Framework connection string?
I'm trying to use the 'Database' NLog target and would like NLog to read my connection string to avoid having to set it twice in the same config file. The problem is I have an Entity Framework-style ...
9
votes
5
answers
2k
views
Reference same Connection String in Multiple .NET Applications
I'm not sure if this is the correct medium for this question, so if it's not please inform me and I will correct.
As an example to illustrate my point, let's say I have 30 .NET applications that are ...
8
votes
5
answers
3k
views
Prompt for Database Connection String
I would like to offer a database connection prompt to the user. I can build my own, but it would be nice if I can use something that somebody else has already built (maybe something built into Windows ...
8
votes
3
answers
3k
views
Changing ELMAH database in code
I have several websites that have separate ELMAH databases. I would like to have one separate website to view all these databases.
I've created a new ASP.NET MVC 4 website for this purpose. I've ...
8
votes
3
answers
3k
views
Regular expression for remove metadata
I trying to create a application with use some Entity Framework and some old DataSets but I only have a dynamic connection string using entity and need remove metadata at runtime to create a ...
8
votes
3
answers
5k
views
What is the purpose of ApplicationServices connection string in Entity Framework Code First scenario?
Whenever you create an application using EF code first you can see follwing web.config key added:
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=...
8
votes
3
answers
4k
views
|DataDirectory| returns wrong path to AppData folder
|DataDirectory|, you had one job. |DataDirectory| on IIS7.5 resolves to:
C:\inetpub\wwwroot\appname\App_Data
That folder does not exist. The correct folder is:
C:\inetpub\wwwroot\appname\bin\...