close
在ASP.NET程式設計中,我們可以在WEB.CONFIG檔中的appSettings區段中設定資料庫連接字串
以便我們在程式中不需要再重複撰寫資料庫連接字串即可對資料庫做存取
相對的,在VB.NET中也可以在app.config檔中如此設定
但是在VB.NET 2005中則有些不同
如果我們還是輸入System.Configuration.ConfigurationSettings.AppSettings的話
錯誤訊息會顯示
已經過時:This method is obsolete,it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings
沒錯,在.Net 2.0中,這個方法已經改用ConfigurationManager來做囉~
所以我們必須在專案中加入System.Configuration的參考
接下來得在app.config中加入appSettings區段,並設定資料庫連接字串
MsgBox(Configuration.ConfigurationManager.AppSettings("ConnectionString"), , "訊息視窗")
全站熱搜