• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • web應用程序中的數據庫連接(1)

    發表于:2007-07-14來源:作者:點擊數: 標簽:
    web.config文件是標準的xml文件,我們可以使用它來為一臺機器下的每一個web應用程序或某個應用程序或一個目錄下的asp .net 頁面來進行設置,當然,它也可以為一個單獨的web頁面進行設置。 如:網站的主目錄是\inetpub\wwwroot\,那么我們將web.config放置于
      web.config文件是標準的xml文件,我們可以使用它來為一臺機器下的每一個web應用程序或某個應用程序或一個目錄下的asp.net頁面來進行設置,當然,它也可以為一個單獨的web頁面進行設置。 

    如:網站的主目錄是\inetpub\wwwroot\,那么我們將web.config放置于其下,那么這個網站中的應用程序將被web.config中的設置所影響。 
    e.g.: 
    <?xml version="1.0" encoding="gb2312" ?> 
    <configuration> 
     <system.web> 
      <compilation defaultlanguage="vb" debug="true" /> 
      <customerrors mode="remoteonly" defaultredirect="js/error.htm"> 
       <error statuscode="404" redirect="js/filenotfound.aspx" /> 
       <error statuscode="500" redirect="js/error.htm" /> 
      </customerrors> 
      <authentication mode="windows" /> 
      <authorization> 
       <allow users="*" /> 
      </authorization> 
      <httpruntime maxrequestlength="4000" usefullyqualifiedredirecturl="true" executiontimeout="45" /> 
      <trace enabled="false" requestlimit="10" pageoutput="false" tracemode="sortbytime" localonly="true" /> 
      <sessionstate mode="inproc" stateconnectionstring="tcpip=127.0.0.1:43444" cookieless="false" timeout="20" /> 
      <globalization requestencoding="gb2312" responseencoding="gb2312" fileencoding="gb2312" /> 
     </system.web> 
     <appsettings> 
      <add key="connstring" value="uid=flash;password=3.1415926;database=news;server=(local)" /> 
     </appsettings> 
    </configuration> 

    這里我們討論一下如何在web.config中設置數據庫連接。 

    1、連接一個數據庫: 
    在web.config中的<configuration>后加入 

    <appsettings> 
        <add key="connstring"  
        value="uid=flash;password=3.1415926;database=news;server=(local)" /> 
    </appsettings> 

    在程序中,你可以使用以下代碼來使用web.config中的設置: 

    -----vb.net----- 
    imports system.configuration 
    dim myvar as string  
     myvar=configurationsettings.appsettings("connstring") 
    -----c#----- 
    using system.configuration; 
    string myvar; 
    myvar=configurationsettings.appsettings["connstring"]; 

    2、連接多個數據庫 
    同理,那就是使用多個不同的key值來設置 


    原文轉自:http://www.kjueaiud.com

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>