---
title: "How to get connection string from app.config file in VC#."  
description: "How to get connection string from app.config file in VC#."  
author: "James Smith"  
published: 2011-07-30  
updated: 2011-07-30  
canonical: https://www.mindstick.com/forum/281/how-to-get-connection-string-from-app-config-file-in-vc-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# How to get connection string from app.config file in VC#.

Hi,

I would like to [access](https://www.mindstick.com/articles/12994/how-foreigners-can-access-blocked-websites-in-china) [connection string](https://www.mindstick.com/articles/328/connection-strings) from app.config [file](https://www.mindstick.com/articles/59/encrypting-and-decrypting-files-using-c-sharp) but am not able to perform it. I am using C# as a [programing language](https://www.mindstick.com/forum/157351/what-is-stack-in-programing-language-explain-it-with-normal-language) and [visual studio](https://www.mindstick.com/articles/12378/visual-studio-for-mac-is-out-of-beta-preview-now-officially-available) 2010 [IDE](https://www.mindstick.com/forum/23226/what-ide-to-use-for-python) on [windows](https://www.mindstick.com/articles/311752/how-to-install-and-use-the-google-wifi-software-on-a-windows-or-mac-computer) 7 64 bit plateform.

Help needed.

Thanks.

## Replies

### Reply by Anonymous User

Hi james,

You can use following line of code to access connection string from app.config file.

```
string cs = System.Configuration.ConfigurationSettings.AppSettings["cs"].ToString();
```

For this app.config file.

```
<?xml version="1.0" encoding="utf-8" ?><configuration>  <appSettings>    <add value="DataSource=a;User Id=ccc;" key="cs"/>  </appSettings></configuration>
```

Thanks.

### Reply by Uttam Misra

James,

Here you go..

http://www.mindstick.com/Articles/6053eec1-02c0-4e09-ab74-c288d8ed41b6/?Connection%20String%20using%20App.config

http://www.mindstick.com/Articles/176ace46-e15b-472c-8dda-f4941639f7f6/?Creating%20Globalized%20Connection%20String%20in%20.Net%20Framework%20using%20Attached%20Database

[https://www.mindstick.com/blog/132/globalized-connection-string](https://www.mindstick.com/blog/132/globalized-connection-string)


---

Original Source: https://www.mindstick.com/forum/281/how-to-get-connection-string-from-app-config-file-in-vc-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
