标题:command.ExecuteReader(CommandBehavior.CloseConnection))是什么意思了?
取消只看楼主
liaohongchu
Rank: 1
等 级:新手上路
帖 子:133
专家分:0
注 册:2008-4-25
结帖率:78.72%
已结贴  问题点数:20 回复次数:1 
command.ExecuteReader(CommandBehavior.CloseConnection))是什么意思了?
public override ProductPropertyCollection GetProductPropertySet(string sql, int pageIndex, int pageSize, bool includePageIndex, bool returnFullThread)
        {
            using (SqlConnection myConnection = new SqlConnection(this.connectionString))
            {
                using (SqlCommand command = new SqlCommand("dbo.[RS_Get_ProductPropertySet]", myConnection))
                {
                     = CommandType.StoredProcedure;

                    command.Parameters.Add("@PageIndex", SqlDbType.Int, 4).Value = pageIndex;
                    command.Parameters.Add("@PageSize", SqlDbType.Int, 4).Value = pageSize;
                    command.Parameters.Add("@sqlPopulate", SqlDbType.NText).Value = sql;
                    command.Parameters.Add("@IncludePageIndex", SqlDbType.Bit).Value = includePageIndex;
                    command.Parameters.Add("@ReturnFullThread", SqlDbType.Bit).Value = returnFullThread;
                    command.Parameters.Add("@TotalRecords", SqlDbType.Int).Direction = ParameterDirection.Output;

                    ProductPropertyCollection productpropertySet = new ProductPropertyCollection();

                    // Execute the command
                    myConnection.Open();
                    using (SqlDataReader dr = command.ExecuteReader(CommandBehavior.CloseConnection))
                    {
                        while (dr.Read())
                        {
                            productpropertySet.Add(PopulateProductPropertyEntryFromIDataReader(dr));
                        }

                        if (includePageIndex)
                        {
                            dr.NextResult();
                            while (dr.Read())
                                productpropertySet.PageIndex.Add(dr[0], dr[1]);
                        }

                        dr.Close();
                        myConnection.Close();
                        productpropertySet.TotalRecords = (int)command.Parameters["@TotalRecords"].Value;
                    }

                    return productpropertySet;
                }
            }
        }


SqlDataReader dr = command.ExecuteReader(CommandBehavior.CloseConnection))

CommandBehavior.CloseConnection  这个找不到哪里定义的? 高手帮忙解答下了? 谢谢!
搜索更多相关主题的帖子: command 
2010-04-07 16:47
liaohongchu
Rank: 1
等 级:新手上路
帖 子:133
专家分:0
注 册:2008-4-25
得分:0 
谢谢 我半路出家, 没有那么专。 工作要看多点。
2010-04-07 23:01



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-302004-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015096 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved