當前位置:九游会j9娱乐平台-九游ag登录中心网址 » 操作系統 » 配置web資料庫

配置web資料庫-九游会j9娱乐平台

發布時間: 2024-01-13 22:49:38

ⅰ 我在web.config中配置連接資料庫,但運行網頁之後出現這種錯誤

方法/步驟
新建一個網站,打開web.config文件,在connectionstring配置節點添加add節點進行資料庫進行資料庫連接配置代碼如下:

connectionstring="server=.;uid=sa;pwd=accp;database=pubs"/>

在設計器中雙擊default.aspx頁面空白處,並 page_load事件處理函數中,添加訪問配置連接字元串代碼:
protected void page_load(object sender,eventargs e)
{
string name="sqlconnection";
string connectionstring=configurationmanager.connectionstrings
["sqlconnection"].connectionstring;
string providername=configurationmanager.connerctionstrings
string providername=configurationmanager.connerctionstrings
["sqlconnection"].providername;
stringbuilder builder=new stringbuilder(string.empty);
builder.appendformat("連接字元串鍵名:{0}
",name);
builder.appendformat("資料庫連接字元串:{0}
",connectionstring);
builder.appendformat("數據t提供程序名稱:{0}
,providername");
this.response.write(builder.tostring());
}
3
運行網站,在default.aspx頁面輸出了配置完成連接字元串

ⅱ jsp開發web網站 怎麼把連接資料庫寫成配置文件調用

一般jsp開發web網站,都是用伺服器容器環境提供的jndi,也就是說,在伺服器的配置文件裡面配好資料庫連接,前提你要把相關需要資料庫連接驅動放到伺服器的lib目錄里,具體的配法識具體伺服器而定,不過一般原始文件都提供伺服器配置demo,你改幾個參數就ok了。

熱點內容
發布:2024-01-20 01:08:21 瀏覽:525
發布:2024-01-20 01:07:17 瀏覽:250
愛奇藝正義聯盟為啥不能緩存 發布:2024-01-20 00:52:13 瀏覽:248
caccess查詢資料庫 發布:2024-01-20 00:43:10 瀏覽:769
xp文件夾圖標更改 發布:2024-01-20 00:43:03 瀏覽:19
python和node 發布:2024-01-20 00:37:12 瀏覽:194
android拖拉 發布:2024-01-20 00:00:49 瀏覽:583
少兒編程課程體系介紹 發布:2024-01-20 00:00:48 瀏覽:846
我說你做下載ftp 發布:2024-01-20 00:00:47 瀏覽:8
安卓驅動培訓哪裡好 發布:2024-01-19 23:55:41 瀏覽:987
网站地图