connection-string

how to define a connection string using an app.config file in C# [duplicate]

ぃ、小莉子 提交于 2019-11-28 04:42:41
问题 This question already has answers here : Get connection string from App.config (18 answers) Closed 5 years ago . Currently i manually define my connection string in my C# code: string ConnectionString = "Data Source=C;Initial Catalog=tickets;Integrated Security=True"; SqlConnection Conn = new SqlConnection(ConnectionString); Conn.Open(); In my project i have an app.config file and i can see that it has a connection string. It looks like this: <?xml version="1.0"?> <configuration>

Quick ways to test OLE DB Connection String

混江龙づ霸主 提交于 2019-11-28 04:39:35
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, maybe from command line on Windows? Because most of the time, it is the client rather than me that would do this task, so I prefer a "zero-installation" approach that would impact their system the least. If the client has PowerShell installed (a given if they are running Windows 7 or Windows Server 2008 R2), then you can execute these commands from a PowerShell console window: $conn = New-Object

.Net Encryption

大憨熊 提交于 2019-11-28 04:24:33
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 interesting in a ClickOnce deployment scenario. I've read about people storing the config unencrypted at the

Set connection string of membership dynamically from code

心不动则不痛 提交于 2019-11-28 03:52:30
问题 I am having a .net web application which uses membership for users validations. The membership has a definition in the web.config file and refer to a connection string in the file(web.config), I need to set the connection string of the membership from the code dynamically not to be static in the web.config. How can i do that? Thanks in advance. 回答1: The following C# sample code demonstrates how to configure a .NET membership provider programmatically by Jacques L. Chereau. This code requires

In C# , how can I read a connection string stored in my web.config file connection string?

跟風遠走 提交于 2019-11-28 03:51:18
问题 In C# class library, how can I read a connection string stored in my web.config file connection string tag? As in: <connectionStrings> <add name="CLessConStringLocal" connectionString="server=localhost;database=myDb;uid=sa;pwd=mypassword;"/> </connectionStrings> 回答1: Use ConfigurationManager.ConnectionStrings collection to access the connection stings that stored in your configuration files. For example : string myConnectionString = ConfigurationManager .ConnectionStrings["CLessConStringLocal

How can I connect to a SDF database? No connection string I try seems to work

时光毁灭记忆、已成空白 提交于 2019-11-28 03:40:30
问题 I've tried literally 50+ different attempts at my connection string for my local database and nothing seems to work. I'm essentially just trying to open a connection the database file so I can dump in the data I've pulled out of my excel spreadsheet. I'm using Visual C# making an offline winform application. No matter what connection string I try in my app.config, it always fails when it tries to write "dReader" to the database. The error is usually this depending on what string I try: "A

Receiving SQLException “Login failed for user” connecting to SQL Server 2008

ε祈祈猫儿з 提交于 2019-11-28 03:39:25
问题 I am trying to connect to SQL Server 2008 via Java. I've added sqljdbc4.jar to my project's library. No username and password is set for database accessing the database (Windows Authentication). The 1433 port is Listening, but I still receive this exception: SQL Exception: com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user ''. ClientConnectionId:085d5df3-ad69-49e1-ba32-b2b990c16a69 Relevant code: public class DataBases { private Connection link; private java.sql.Statement

How to set “Application Name” in ADODB connection string

人走茶凉 提交于 2019-11-28 03:34:30
问题 In .NET I simply use Application Name = MyApp inside the connection string, but when using ADO connection through VBA the Activity Monitor of the SQL Server Management Studio always shows Microsoft Office 2010 in Processes on the Application column no matter what name I set on the VBA code. conn.ConnectionString = "UID=" & UID & ";PWD=" & PWD & ";DSN=" & DSN & _ ";Application Name = MyApp" How can I set the application name for monitoring purposes? 回答1: Ahh I see VBA connection string doesn't

The web publishing extension is not installed which is required to publish

折月煮酒 提交于 2019-11-28 02:54:31
问题 I was tring to deploy an ASP.NET Web Application to a Windows Azure Web Site by following the tutorial through this link: https://www.windowsazure.com/en-us/develop/net/tutorials/get-started/ After download the public profile, which is a ".PublishSettings" file, I go back to Visual Studio and right-click the project in Solution Explorer and select Publish from the context menu as the tutorial said. However, a warning box jumped up and it showed me that "The Web Publishing extension is not

Using a relative path in connection string for Access DB in C#

梦想与她 提交于 2019-11-28 02:04:29
I'm trying to get this line in my web.config file to use a relative path instead of hardcoded one, but nothing seems to be working. I can only find stuff for SQL and mySQL DBs <connectionStrings> <add name="dbConnection" connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Mike\Desktop\GeauxEat NEW\GeauxEat\App_Data\GeauxEatAccessDB.accdb"/> </connectionStrings> I tried making it <add name="dbConnection" connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|Data Directory|\GeauxEatAccessDB.accdb"/> but then it looks for something in this folder where it doesn't