retrieving connection string w/ ConfigurationManager

I am trying to store and retrieve connection string info from config 
file and I am having trouble retrieving the connection string info.

I stored the info with the following:

Configuration config = null;
config = 
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None );
config.ConnectionStrings.ConnectionStrings.Add(
         new ConnectionStringSettings(
         "MyConfigurationString",
         "Server=local;Database=Test;Password=password;User Id=john;" ) );
config.Save();

I then remove the Add method and use the following try to retrieve the 
configuration info with the following:

Configuration config = null;

config = 
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None );

string stuff = 
config.ConnectionStrings.ConnectionStrings["MyConfigurationString"].ConnectionString;

this fails because the value

config.ConnectionStrings.ConnectionStrings["MyConfigurationString"];

returns null;

the configuration file has the following:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
     <connectionStrings>
       <add name="MyConfigurationString" 
connectionString="Server=local;	Database=Test;Password=password;User 
Id=john;" />
     </connectionStrings>
</configuration>


please excuse the formatting, thunderbird messages are a little hard to 
work with

thanks for the help

john
0
coltrane
5/20/2010 12:38:50 PM
sqlserver.programming 1873 articles. 0 followers. Follow

0 Replies
646 Views

Similar Articles

[PageSpeed] 27

Reply:

Similar Artilces:

Office Update 10.2.3 kills network connections to shares.
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel Don't ask me why, but I witnessed this myself. I just did a clean install on a 27&quot; iMac updated the OS to 10.6.2 set up several SMB shares and ran the final office update 10.2.1.(which I had disk images of) I left the clients place telling him to use the software update on MS Office for the remaining updates. He updated his Office to 10.2.3 and it killed the ability to connect to the shares I had already set up. I went back and tried to reconnect the shares and the &quot;Connect to Server&qu...

Can't Send email to AOL accts, SBS w/exchange
I have a 2003 SBS server that has exchange set up through a pop3 conector. All email will send and receive with no issues, except for AOL.....We can receive the emails, but can't send. We have tried switchin the email accts on the toolbar next to "send" from the default microsoft exchange server, to the actual domain user@mydomain.com, still to no avail. Any help is apprecitated.. thanks, mark "mark" <mark@discussions.microsoft.com> wrote: >I have a 2003 SBS server that has exchange set up through a pop3 conector. All email will send and receive with ...

"Unable to connect to server" error 800ccc0e/800cccoe
I've gotten this error before, normally it means the server is unresponsive or non-existent. The problem I have is that I can ping the server, login using Horde (webmail) on the same server and-- worst of all-- can even use the server's I.P. address without any response. I also fail to send through any SMTP server, whether my own or my ISP's. I don't have Pc-Cillin installed, as the Outlook Support site suggested, but I am running Norton Antivirus. Is there anything else that could possibly cause this issue? Thanks! - Quiller quiller@equiller.com Try turning off ou...

2003 org connected to 2003 org....but with same email addresses
Hi I am starting a domain migration, but ideally we want to setup users from scratch. Currently we have an exchange 2003 organisation, with front and backend servers, and we want to leave the mail flowing into that org during the staged migration.....we then want to create a new exchange environment on the new domain. The users will have the same email addresses. Will the ADC cope with this? so in essense mail will flow to to the old exchange server, but then if it doesn't find a account with the email address as I would have either deleted it or removed the SMTP address, I then need i...

new to pub
I am just beginning to try pub. book in software box is minimal Have a ms access report of name/addr - phone book style I need to put this member phone book report into a yearbook in pub can I bring in my ms access report? how?? if not, what about as a mail merge? if not, then how - without having to retype all those names, addr, ph,etc thanks for any help ann in dallas You are better exporting the information from Access to CSV (Comma Separated Value) and use the CSV file with Publisher. That is the only reliable and functional way. I cannot understand people that use such a disgusting...

CRM connection to subsidiary
Hi, we have introduced MS CRM with an own CRM Server. On this CRM Server we have also implemented a SQL Server. Additionally we use an own Exchange Server 2003 and Active Directory. In near future we face the CRM connection to our subsidiary which has to get access to our CRM system. They have their own Exchange Server 2003 but should - if possible - not have an own CRM Server. Has anyone experience regarding this problem and give us some advice? Is a CRM-connection to our subsidiary with these conditions possible? Thank you very much for your help!! Angela Hello Angela. This is Krish...

Chart w/Secondary Axis
I'm trying to create a chart that shows dollar values on one side and % on the other. There are a total of 5 data series that need to show on the secondary axis, ranging from -3% to 45%. I can not get all of the data series to show up on the chart. I've been able to get 2 of the 5 to show up by just right clicking around the chart. I've changed the range of values on the secondary axis to show -5% to 50% and they still don't show up. Any suggestions would be greatly appreciated!! Don't use the built in types with two axes. Put all your data into the chart using a ...

How do I add the next month to a calendar w/o loosing cust format
Created a calendar page for the office with custom logo and address info. The calendar wizard changes everything back to the default when changing the date range. Help file says to add dates to retain custom elements but not 'How' to add dates. What's the best way to create a custom calendar and retain the formatting? The address lines and the logo are determined by your personal information. Look under Edit, the personal information is the very last item in the menu. -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com ...

Paste Special Problem w/ Excel Chart
Microsoft states ... To paste Excel data or a chart into a PowerPoint slide On the Edit menu, click Paste Special. To paste the data as an Excel range, so that when you double-click the range in the presentation you can edit it with Excel, click Microsoft Excel Worksheet Object. If data is cut off, double-click the object and resize the columns to show all the data. THE PROBLEM!! Several columns of data are being "cut off", and nothing I do will get them to appear in the slide. I have tried several Excel files with charts, and everyone of them cuts off the same columns...

Sites & Services
My University has a 2003 native mode forest that contains one root domain and seven child domains. The 8 domains contain a total of 26 domain controllers that communicate and replicate in the forest. Schools and major administrative units on campus have deployed firewalls to segregate and control traffic to/from their network subnet and the campus enterprise network. Consequently the firewalls inspect and permit or deny traffic among the 26 domain controllers. All the DCs replicate information in a mesh topology without issue. Currently the Sites and Service topology is "flat&q...

Count partial matched text string
I have 3 spreadsheets. The first, “Supplies Requests Received” where Column B contains the (duplicated) names of internal offices placing supply requests (e.g., SNF, DGEN, CANM, etc.) and Column G contains each date a request for supplies was received from that office. Column B Column B SNF 1//29/2009 DGEN 4/19/2008 CNMN 2/4/2009 ASEV 12/11/2008 SNF 2/3/2009 ASEV 9/16/2008 DGEN 5/1/2008 The second spreadsheet “Supplies Delivered” where Column A is a link of Column B from the above “Supplies Requests Received spreadsheet and Column G (of Supplies Delivered”) contains the names of ALL ...

Retrieving Windows' color settings
How do I retrieve Windows' color settings? For example, the default Windows Text is black and background is white. How do I retrieve the color (RGB values) for the Windows background? Have a look at GetSysColor API Victor "Charles Tam" <CharlesTam@discussions.microsoft.com> wrote in message news:811FC86C-4703-433E-B529-A180F46CED79@microsoft.com... > How do I retrieve Windows' color settings? > For example, the default Windows Text is black and background is white. > > How do I retrieve the color (RGB values) for the Windows background? use SystemPa...

Microsoft ADAM EdgeSync 4 hour for Recipient Data? New usrs must w
I am trying to get recipient information updated manually or more often than 4 hours. Based on the docs: >Configuration data is synchronized at one-hour intervals. Recipient data is >synchronized at four-hour intervals. If you have made significant changes to data >in Active Directory, you may want to synchronize immediately. You can use the >Start-EdgeSynchronization cmdlet in the Exchange Management Shell to start >immediate synchronization. I have run Start-EdgeSynchronization without any errors, but when I run, [PS]>Test-EdgeSynchronization Name ...

tools, option, send immediatley when connected
team so i've got this question about outlook.. i always go through and uncheck 'send immediately when connected' this works great- --- sometimes i need to double-check my emails before sending them out.. why is it that when i go 'file, sendto, mail recipient as attachment' in excel-- why doesn't this email (with the XLS attachment) _STAY_ in my outbox until i hit send/recieve? i mean-- seriously? is it a BUG? is it a feature? is there a way to make 'send immediately when connected' really work like it should?? ...

Keyboard Shortcut to toggle b/w Find and Replace and Active Worksheet?
Hi: I open the Find and replace Dialogue Box using CTRL+F and then enter the value I am looking for. Excel moves the cursor to the cell in question with the found value. Is there anyway to then use the keyboard to move from the dialogue box into the actual worksheet, without having to mouse click back into the open file? It seems there has to be some type of way to use the keyboard to move from the Find Dialogue box without using the mouse. I hope I am being clear on what I am trying to do, it seems very simple yet I cannot figure out what keyboard command to use to basically select the Exce...

OL 2003 drops connection to Exchange 2000
I have been running Exchange 2000 on a Small Business Server for 3 years and it has always worked reliably inside our network until we added some Outlook 2003 clients on new machines. The OL 2003 clients get locked up for 3-5 minutes at a time although they still have access to other network devices as well as the web. This happens 2-3 times daily for each OL 2003 client. Is there a compatibility problem, e.g. protocols, between Exchange 2000 and Outlook 2003? Thanks, Bill ...

Account gets updated everytime it connects
I have MS Money 2004 Deluxe. Everytime I allow automatic updates or force a manual update, 1 account always has activity. The top says you have no unread statements, but it will have an arrow with a (5). 5 is the number of funds in this account. I click OK a couple of times and it doesn't change anything. It's like it's just checking the balance or something. I have another account with the same company that doesn't do this. Ideas? Thanks In microsoft.public.money, Mick0866 wrote: >I have MS Money 2004 Deluxe. Everytime I allow automatic updates or force a >...

Remote Connectivity
When using terminal server on your personal computer, can the personal activities that you conduct such as MSN messenger, websites visited on your local computer be seen by the network, after you log off of the remote desktop connection? I notice that even once you sign off, there's a message that states the remote connection is still running in the background. Please advise ...

Access97 Queries connecting via ODBC to Sybase SQLanywhere backend
I have a Access97 frontend database and it links tables and queries to a Sybase SQLAnywhere backend database. I have imported all the tables from the SQLAnywhere into a Access97 database. I have changed the linked relationship in the tables section to point to the Access97 backend now and not the Sybase backend. Problem is I have SQL queries written in the Access 97 frontend that still try to access Sybase via ODBC. How do I change these queries to access the new Backend. Jamie Network Administrator If the queries were originally written using linked tables, they should still work. Ho...

business contact manager w/ outlook 2003
would really like to sync with pocket pc - any suggestions? ...

CListCtrl w/ LVS_OWNERDRAWFIXED
I have an owner drawn CListCtrl with LVS_REPORT style. I want to draw my own thing in one of the columns only. The rest of the columns I'd like to appear just as if the CListCtrl was not owner-drawn. What's the easiest way to accomplish this? The code I have from http://codeguru.earthweb.com/listview/sel_row.shtml includes code to draw standard text in the same style as the standard list control, but if possible I'd like to remove that and just have the standard list control process the drawing of the other columns. Thanks, David http://www.dcsoft.com "David Chin...

How do I open a form w/ the last record showing first?
This is probably simple, but I can't seem to figure it out. How do you have the last record in a table so first when you open a form linked to that table. You can have OnOpen event call a macro action of GoToRecord but how do you determine which is the last records as Access stores them like a barrel of bricks, no set order. Better would be to use FindRecord. -- Build a little, test a little. "forchem" wrote: > This is probably simple, but I can't seem to figure it out. How do you have > the last record in a table so first when you open a form ...

Retrieving values from XML file
I want to be able access an xml file using an XPath? query to go to a specific node. Once I have that node I want to be able to retrieve the value of an attribute. Can't seem to get this working using the 2.0 Framework. Here's a sample of the XML <Agency> <vu_Agency AgencySysNo="1" Name="Dept 1"/> <vu_Agency AgencySysNo="2" Name="Dept 2"/> </Agency> The code I'm playing with is... Dim document As XPathDocument = New XPathDocument(ConfigurationManager.AppSettings("xmlPath").ToString() & "A...

Sorting cells with a string formulas
In trying to split addresses which contain both number and street in one cell, I have extracted using these formulas: =REPLACE(B5,1,FIND(" ",B5,1)-1,"") and this one: =LEFT(B5,FIND(" ",B5,1)-1). They yield a number and a street in separate cells. They work great but then trying to sort does not work. Help. Erik (a Word 2007 user) What to you mean by "does not work". What happens when you try to sort? Regards, Fred "Erik" <Erik@discussions.microsoft.com> wrote in message news:D377AAD9-D7E1-4971-A8F8-E0C6673E3AEA@microsof...

SMTP Connection aborted when sending meeting requests
Hi, hope somebody can help me with a really strange problem: Exhange 2003, single server installation Since a couple of weeks we are encountering problems when sending meeting requests to external email addresses. The requests will be never received (I'm not talking about the format or something - the recepient doesn't get anything) and after Exchange gave up trying to send it, the user gets an error mail. I tracked the problem down to the packet layer: When the Exchange/SMTP Server is trying to send a meeting request, it starts with the standard SMTP conversation: EHLO mydoma...