標籤: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%