thenthorn1010
asked on
Blank Connection String Issues
I am attempting to use a local file to store the logon information for a ASP.NET site made in C#, and I am getting an empty string returned when I attempt to use the following code to open the connection:
OracleConnection conn = new OracleConnection();
conn.ConnectionString = WebConfigurationManager.Ap pSettings[ "SampleCon nectionStr ing"];
conn.Open();
After I get to the conn.Open() line of code, I receive a "general error" due to the SampleConnectionString values not being read into the site. The file that contains the connection string has the following line of code within it and is called appsettings.txt:
<appSettings >
<add key="SampleConnectionStrin g" value="Data Source=WEB;Enlist=false;Us er ID=user;Password=1234;" />
</appSettings>
Any help that can be provided about why this string, which is included in the project, is not being pulled back into the WebConfigurationManager.Ap pSettings call would be greatly appreciated.
OracleConnection conn = new OracleConnection();
conn.ConnectionString = WebConfigurationManager.Ap
conn.Open();
After I get to the conn.Open() line of code, I receive a "general error" due to the SampleConnectionString values not being read into the site. The file that contains the connection string has the following line of code within it and is called appsettings.txt:
<appSettings >
<add key="SampleConnectionStrin
</appSettings>
Any help that can be provided about why this string, which is included in the project, is not being pulled back into the WebConfigurationManager.Ap
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
jagssidurala,
I wanted to apologize...I did find an error in the web.config file that was referencing an invalid location for the appsettings, which would cause the "general error." I did attempt your method and you are correct in the solution to the question I asked.
pateljitu and binaryevo,
I also did verify, after finding the issue in the web.config file, that your methods are valid as well.
All three of you did answer my question completely. Thank you for the help.
I wanted to apologize...I did find an error in the web.config file that was referencing an invalid location for the appsettings, which would cause the "general error." I did attempt your method and you are correct in the solution to the question I asked.
pateljitu and binaryevo,
I also did verify, after finding the issue in the web.config file, that your methods are valid as well.
All three of you did answer my question completely. Thank you for the help.
ASKER
I did attempt your suggestion and while it does compile, I still end up with a "general" error. Thank you for the suggestion though.