亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

從web.config讀取連接字符串

從web.config讀取連接字符串

智慧大石 2019-11-26 13:06:24
如何從web.config文件讀取連接字符串到類庫中包含的公共類中?我試過了:WebConfigurationManagerConfigurationManager但是這些類在我的類庫中無法識別。
查看完整描述

3 回答

?
翻翻過去那場雪

TA貢獻2065條經驗 獲得超14個贊

您需要添加一個引用System.Configuration,然后使用:


System.Configuration.ConfigurationManager.

    ConnectionStrings["connectionStringName"].ConnectionString;


查看完整回答
反對 回復 2019-11-26
?
手掌心

TA貢獻1942條經驗 獲得超3個贊

C#


// Add a using directive at the top of your code file    

using System.Configuration;


// Within the code body set your variable    

string cs = ConfigurationManager.ConnectionStrings["connectionStringName"].ConnectionString;

VB


' Add an Imports statement at the top of your code file    

Imports System.Configuration


' Within the code body set your variable    

Dim cs as String = ConfigurationManager.ConnectionStrings("connectionStringName").ConnectionString


查看完整回答
反對 回復 2019-11-26
  • 3 回答
  • 0 關注
  • 668 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號