<?xml version="1.0" encoding="utf-8" ?>可以直接用configurationmanager讀取:
string constr = configurationmanager.connectionstrings["sqlstring"].connectionstring;
追問
工程中是有乙個web.config,但是我自己新建了乙個xml檔案,內容如提問所示。我先從自己寫的xml問價你中讀取連線資料庫的字串,而不是從web.config中讀取。就是想練習xml的讀寫,言歸正傳,怎麼得到xml檔案的路徑回答
xmldocument xmldoc = new xmldocument();xmldoc.load("config.xml");
xmlnode connode= xmldoc.selectsinglenode("configuration/connectionstrings/add[@name='sqlstring']");
string conn = connode.attributes["connectionstring"];
基本上是這樣的~
資料庫連線,讀取
連線sql server sqlconnection myconnection new sqlconnection persist security info false integrated security sspi database dream server local myconnectio...
C 連線MySQL資料庫並讀取資料
以讀取資料為例 1 第一步,要將你的c 程式與mysql連線起來,這裡要用到函式mysql real connect 2 第二步,執行查詢語句,這裡要用到函式mysql query 3 查詢語句查詢到的結果,稱為結果集,第三步就是要將結果集中的所有資料,存放在乙個變數a中,型別為mysql res ...
C 中讀取資料庫資料的問題
程式首先是要判斷一天資訊是否存在於資料庫中,然後若存在則將資料展示在頁面的listview中。用來兩種方法 1.用adapter private static string strconnect provider microsoft.jet.oledb.4.0 data source c users...