Ado.Net初學者進度條-30%

來源:互聯網
上載者:User

標籤:color   串連數   通過   資料庫   query   dll   manage   span   需要   

Ado.Net-------------------------------
訪問資料庫的驅動-ado.net

 

SqlConnection:

更多關於SqlConnection資訊:http://www.cnblogs.com/LoveJenny/archive/2011/10/31/2229738.html
  負責串連資料庫。伺服器Ip,使用者名稱,密碼,資料庫名。

  server=.;uid=sa;pwd=123;database=... //通過使用者名稱密碼串連
  server=.;Integrated Security=SSPI;database=... //通過windows驗證串連

SqlCommand:

更多關於SqlCommand詳細資料:http://www.cnblogs.com/kissdodog/p/3334579.html

  sql命令的封裝,有重載,可以把connection直接給sqlcommand
  ExecuteNonQuery():返回執行sql語句後幾行受影響,返回int類型
  ExecuteScalar() :返回查詢結果第一行,第一列的資料,返回Object

 

 

設定檔,config--------------
config檔案的更多詳細資料:http://www.cnblogs.com/fish-li/archive/2011/12/18/2292037.html
把可能需要改動的資料,放在App.config或web.config
<connectionStrings>
<add name="SqlConfig" connectionString="server=.;Integrated Security=SSPI;database=db_Demo"/>
</connectionStrings>

那我們怎麼用呢?記得引用 system.configuration.dll
ConfigurationManager.ConnectionStrings["config中的name"].ConnectionString;

 

//留給自己的疑問
SqlCommand cmd = new SqlCommand()
SqlCommand cmd = conn.CreateCommand()
兩個之間有什麼區別?

Ado.Net初學者進度條-30%

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.