[問題] using SqlConnection 問題
各位好
想請教一個問題
public sealed class ConnectionManager
{
public static SqlConnection GetWebConnection()
{
string connectionString =
ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlConnection connection = new SqlConnection(connectionString);
connection.Open();
return connection;
}
}
===============================================
請問如果我這樣寫
using (SqlCommand command = new SqlCommand(sql,
ConnectionManager.GetWebConnection()))
{
//my statment
}
是不是不用再close connection?
感謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 202.175.124.66
推
01/15 12:58, , 1F
01/15 12:58, 1F
→
01/16 14:20, , 2F
01/16 14:20, 2F
→
01/16 14:20, , 3F
01/16 14:20, 3F
→
01/16 18:34, , 4F
01/16 18:34, 4F
C_Sharp 近期熱門文章
PTT數位生活區 即時熱門文章