PC Review


Reply
 
 
Tony Johansson
Guest
Posts: n/a
 
      6th Apr 2011
I try to read app.config from my program by using the following code.
private SqlConnection GetSqlConnection()
{
ConnectionStringSettings settings =
ConfigurationManager.ConnectionStrings[BLACKJACK];
if (settings == null)
{
throw new ArgumentException(BLACKJACK + " was not found as
a connectionstring name");
}

SqlConnection sqlConnection = new SqlConnection();
sqlConnection.ConnectionString = settings.ConnectionString;

return sqlConnection;
}

The problem is that I read machine.config instead of app.config.
So my question is how do I do to make the program read app.config ?

//Tony


 
Reply With Quote
 
 
 
 
Tony Johansson
Guest
Posts: n/a
 
      6th Apr 2011
Forget this question !

//Tony
"Tony Johansson" <(E-Mail Removed)> skrev i meddelandet
news:inhbsj$q3q$(E-Mail Removed)...
>I try to read app.config from my program by using the following code.
> private SqlConnection GetSqlConnection()
> {
> ConnectionStringSettings settings =
> ConfigurationManager.ConnectionStrings[BLACKJACK];
> if (settings == null)
> {
> throw new ArgumentException(BLACKJACK + " was not found as
> a connectionstring name");
> }
>
> SqlConnection sqlConnection = new SqlConnection();
> sqlConnection.ConnectionString = settings.ConnectionString;
>
> return sqlConnection;
> }
>
> The problem is that I read machine.config instead of app.config.
> So my question is how do I do to make the program read app.config ?
>
> //Tony
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
dll config and web.config and Label Expressions (binding label text to dll config settings) CSharpner Microsoft ASP .NET 0 9th Apr 2007 10:00 PM
DTDs for machine.config, web.config, security.config available ? =?Utf-8?B?UGF1bCBLZW5uZWR5?= Microsoft Dot NET Framework 1 5th Feb 2007 05:42 AM
sharedListeners config in app.config file doesn't recognize customlocation attribute RJ Microsoft Dot NET 0 1st Nov 2006 08:48 PM
using ReadXml to read exe.config file into Grid and update the exe.config using WriteXml hazz Microsoft C# .NET 0 7th Jul 2006 10:32 PM
Configuration Error - c:\winnt\microsoft.net\framework\v1.1.4322\Config\machine.config Ivan Microsoft ASP .NET 1 21st May 2004 05:18 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:00 PM.