Obselete COnnection String
hello guyz!! currently, i have this code(C# 2005) below to connect to my SQL 2005 Express edition
Code:
Code:
string sqlConnStr;
sqlConnStr = System.Configuration.COnfigurationSettings.AppSettings["ConnectionString"];
SqlConnection sqlConn = new SqlConnection(sqlConnStr);
slqConn.Open
App.COnfig (excerpt)
Code:
<appSettings>
<add key="ConnectionString" value="Data SOurce =....." />
</appSettings>
But it seems that the Method is obselete and according to Visual Studio 2005 it has been replaced by System.Configuration! System.Configuration.COnfigurationManager.AppSetting'. My question is how can i enhance it? thanks in advance!!!
Re: Obselete COnnection String
The config file and its handling has been beefed up in VS 2005. You should create your connection string on the Settings tab of the project properties. You can create it as type String and just type in the value or you can create it as type ConnectionString and create it by point and click. Either way, assuming that you create a setting named MyConnectionString you would retrieve it in code like so:
Code:
SqlConnection con = new SqlConnection(Properties.Settings.Default.MyConnectionString);
If you create your connection in the designer you can bind the ConnectionString property to the setting in the ApplicationSettings section of the Properties window. In fact, you can even create the setting from there.
Re: Obselete COnnection String
Thanks a lot...it really helps me..Thanks for the info. again!