C# SqlDataAdapter是否需要打开连接才能执行Sql命令
SqlDataAdapter是否需要打开连接才能执行Sql命令 见下文:C# SqlDataAdapter是否需要打开连接才能执行Sql命令,c#,sql,asp.net,ado,C#,Sql,Asp.net,Ado,SqlDataAdapter是否需要打开连接才能执行Sql命令 见下文: protected void Page_Load(object sender, EventArgs e) { string strconn = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString; SqlConnection con = new SqlConnection(strconn);
protected void Page_Load(object sender, EventArgs e)
{
string strconn = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
SqlConnection con = new SqlConnection(strconn);
SqlCommand cmd = new SqlCommand("Select * from EmpDetails", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
GV_Data.DataSource = ds;
GV_Data.DataBind();
}
有人对此有线索吗?没有。DataAdapter将在填充数据集/表之前自动打开关闭的连接。它还将使连接返回到填充操作之前的状态是否注意到任何异常情况?