hi need help with configurationmanager
-
SqlConnection conn = new SqlConnection((ConfigurationManager.ConnectionStrings["HASDBConnectionString1"]).ToString());
hi the above code is what i used in my asp.net to get the connection string from the web.config now i am trying to get the connection string for my c# window application using visual studio 2005 project but it sseems the same code dont work can any one show me how? -
SqlConnection conn = new SqlConnection((ConfigurationManager.ConnectionStrings["HASDBConnectionString1"]).ToString());
hi the above code is what i used in my asp.net to get the connection string from the web.config now i am trying to get the connection string for my c# window application using visual studio 2005 project but it sseems the same code dont work can any one show me how?Check System.Configuration namespace. alternatively My suggestion is to create custom ConfigurationManager sigleton class , initialize at the startup. BAIJUMAX :cool: "Coolest thing on earth is...? Guess what? as per my knowledge 'ICE' , anythingelse pl's let me know ":-O
-
Check System.Configuration namespace. alternatively My suggestion is to create custom ConfigurationManager sigleton class , initialize at the startup. BAIJUMAX :cool: "Coolest thing on earth is...? Guess what? as per my knowledge 'ICE' , anythingelse pl's let me know ":-O
In desktop application u should use System.Configuration.ConfigurationSettings.AppSettings.Get("ElementName")
-
In desktop application u should use System.Configuration.ConfigurationSettings.AppSettings.Get("ElementName")
<configuration> <add name="HASDBConnectionString1" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\HASDB.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/> </configuration> hi the above is the part of the configuration file that i am trying to get.. the connection string part. i tried your method but it doesnt seems to work could you please try to help me again pls?
-
<configuration> <add name="HASDBConnectionString1" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\HASDB.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/> </configuration> hi the above is the part of the configuration file that i am trying to get.. the connection string part. i tried your method but it doesnt seems to work could you please try to help me again pls?
you have to modify your app.config file to look like above. then u can use what i said earlier.. try it and if u still not been able to do it. then i'll make a sample for u.
-
you have to modify your app.config file to look like above. then u can use what i said earlier.. try it and if u still not been able to do it. then i'll make a sample for u.