2011-04-28 27 views
0

顯然沒有人將可視化Web開發表達式與數據庫連接起來,因爲我無法在Google上找到任何有用的東西。ASP.NET數據庫選項

  1. 我是否需要將數據源連接到我的項目,以便登錄控制/ etc工作?如果沒有,還有其他什麼?
  2. 什麼(免費!)數據庫可以用作視覺Web開發中的數據源表達?
  3. 我該如何連接它們?

我的問題有點短,但我得走了,在此先感謝。

回答

1

答案就在這裏Using the Web.Config to set up my SQL database connection string?

這就是你所需要的!

UPDATE

一個小例子: 首先參考System.Configuration添加到您的項目,然後進口在你的代碼(使用System.Configuration)。

DataSet ds = new DataSet(); //Create a DataSet 
string ConnectionString = ConfigurationManager.ConnectionStrings["YourConnectionStringName"].ConnectionString; //ConnectionString from web.config 
SqlConnection con = new SqlConnection(); //Create a new SqlConnection 
con.ConnectionString = ConectionString; //Connect using your ConnectionString 
SqlDataAdapter da = new SqlDataAdapter("Your SQL query goes here", con); //Get Data 
da.Fill(ds); //Fill a DataSet (in this case) 
con.Close(); //Close connection 
+0

好的,我有一個連接字符串,但我該怎麼辦呢?我已經將它添加到web.config 下,但是如何告訴VWD使用並連接到它? – Dan 2011-04-28 21:11:43

+0

我希望我的更新可以幫助你 – christiangobo 2011-04-29 15:20:40