sqldatareader 问题
publicSqlDataReaderArticleUpdateShow(stringnewid){SqlConnectionmyConnection=newSqlCon...
public SqlDataReader ArticleUpdateShow(string newid)
{
SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["BusinessConn"].ToString());
SqlCommand myCommand = new SqlCommand("ArticleUpdateShow", myConnection);
myCommand.CommandType = CommandType.StoredProcedure;
SqlParameter param = new SqlParameter("@NewId", SqlDbType.BigInt, 8);
param.Value = newid;
myCommand.Parameters.Add(param);
SqlDataReader reader = null;
try
{
myConnection.Open();
reader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
return reader;
}
catch
{
return null;
}
}
大家帮忙看一下这个方法呀,我现在有点怀疑,当我调用这个方法的返回类型SqlDataReader的close()方法时,是否真的能关闭myConnection的连接呢,大家都来说说,效率会高吗????能关闭数据连接吗,读完数据时 展开
{
SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["BusinessConn"].ToString());
SqlCommand myCommand = new SqlCommand("ArticleUpdateShow", myConnection);
myCommand.CommandType = CommandType.StoredProcedure;
SqlParameter param = new SqlParameter("@NewId", SqlDbType.BigInt, 8);
param.Value = newid;
myCommand.Parameters.Add(param);
SqlDataReader reader = null;
try
{
myConnection.Open();
reader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
return reader;
}
catch
{
return null;
}
}
大家帮忙看一下这个方法呀,我现在有点怀疑,当我调用这个方法的返回类型SqlDataReader的close()方法时,是否真的能关闭myConnection的连接呢,大家都来说说,效率会高吗????能关闭数据连接吗,读完数据时 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询