How to call connection string from web.config
-
Hi, I stored connection string in web.config file. and I call it in c# program as follows. SqlConnection cn; sConn = ConfigurationSettings.AppSettings("dbconnection"); cn = new SqlConnection(sConn); cn.Open(); then it is giving a error message 'System.Configuration.ConfigurationSettings.AppSettings' denotes a 'property' where a 'method' was expected please I am a new programmer. can anyone help me? Thank you.
-
Hi, I stored connection string in web.config file. and I call it in c# program as follows. SqlConnection cn; sConn = ConfigurationSettings.AppSettings("dbconnection"); cn = new SqlConnection(sConn); cn.Open(); then it is giving a error message 'System.Configuration.ConfigurationSettings.AppSettings' denotes a 'property' where a 'method' was expected please I am a new programmer. can anyone help me? Thank you.
-
kinnuP wrote:
u
kinnuP wrote:
r
Please write properly - TXTSPK is difficult to understand and you are not constrained to 160 characters.
kinnuP wrote:
This question was NOT specific to ASP.NET. The answer, which YOU gave, was a correction of C# syntax - Other than a reference to web.config (and it could just have easily been app.config, because the C# code to access that is no different), it had nothing to do with ASP.NET.
Upcoming Scottish Developers events: * We are starting a series of events in Glasgow in 2007. Are you interested in a particular subject, or as a speaker? * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog | Photos
-
kinnuP wrote:
u
kinnuP wrote:
r
Please write properly - TXTSPK is difficult to understand and you are not constrained to 160 characters.
kinnuP wrote:
This question was NOT specific to ASP.NET. The answer, which YOU gave, was a correction of C# syntax - Other than a reference to web.config (and it could just have easily been app.config, because the C# code to access that is no different), it had nothing to do with ASP.NET.
Upcoming Scottish Developers events: * We are starting a series of events in Glasgow in 2007. Are you interested in a particular subject, or as a speaker? * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog | Photos
-
I tried it again with App.config file. but same error is comming. pls can you help me? Thanks
Probably not an error, but a warning. The appsettings is obsolete since VS.NET 2005. Create a reference to System.Configuration and use : System.Configuration.ConfigurationManager.AppSettings["SettingName"]; That should do the trick ;-)
- - - --[ i love it when a plan comes together ]-- - - -
-
Probably not an error, but a warning. The appsettings is obsolete since VS.NET 2005. Create a reference to System.Configuration and use : System.Configuration.ConfigurationManager.AppSettings["SettingName"]; That should do the trick ;-)
- - - --[ i love it when a plan comes together ]-- - - -
:((I tried that again, then it is an another error called: The type or namespace name 'ConfigurationManager' does not exist in the class or namespace 'System.Configuration' (are you missing an assembly reference?) I am a beginner for c# can you help me? thank you