当前位置: 首页>>代码示例>>C#>>正文


C# IDataReader.Close方法代码示例

本文整理汇总了C#中IDataReader.Close方法的典型用法代码示例。如果您正苦于以下问题:C# IDataReader.Close方法的具体用法?C# IDataReader.Close怎么用?C# IDataReader.Close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDataReader的用法示例。


在下文中一共展示了IDataReader.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: NDataReader

		/// <summary>
		/// Creates a NDataReader from a <see cref="IDataReader" />
		/// </summary>
		/// <param name="reader">The <see cref="IDataReader" /> to get the records from the Database.</param>
		/// <param name="isMidstream"><see langword="true" /> if we are loading the <see cref="IDataReader" /> in the middle of reading it.</param>
		/// <remarks>
		/// NHibernate attempts to not have to read the contents of an <see cref="IDataReader"/> into memory until it absolutely
		/// has to.  What that means is that it might have processed some records from the <see cref="IDataReader"/> and will
		/// pick up the <see cref="IDataReader"/> midstream so that the underlying <see cref="IDataReader"/> can be closed 
		/// so a new one can be opened.
		/// </remarks>
		public NDataReader(IDataReader reader, bool isMidstream)
		{
			ArrayList resultList = new ArrayList(2);

			try
			{
				// if we are in midstream of processing a DataReader then we are already
				// positioned on the first row (index=0)
				if (isMidstream)
				{
					currentRowIndex = 0;
				}

				// there will be atleast one result 
				resultList.Add(new NResult(reader, isMidstream));

				while (reader.NextResult())
				{
					// the second, third, nth result is not processed midstream
					resultList.Add(new NResult(reader, false));
				}

				results = (NResult[]) resultList.ToArray(typeof(NResult));
			}
			catch (Exception e)
			{
				throw new ADOException("There was a problem converting an IDataReader to NDataReader", e);
			}
			finally
			{
				reader.Close();
			}
		}
开发者ID:tkellogg,项目名称:NHibernate3-withProxyHooks,代码行数:44,代码来源:NDataReader.cs

示例2: ClientSearch

        protected virtual void ClientSearch(object sender, System.EventArgs e)
        {
            try {
                string sql = "SELECT * FROM clients WHERE id>=0 ";
                if (this.EntryClientName.Text!="") sql+=" AND name='"+this.EntryClientName.Text+"'";
                if (this.EntryClientSurname1.Text!="") sql+=" AND surname1='"+this.EntryClientSurname1.Text+"'";
                if (this.EntryClientSurname2.Text!="") sql+=" AND surname2='"+this.EntryClientSurname2.Text+"'";
                Console.WriteLine(sql);
                IDbCommand dbcmd = dbcon.CreateCommand();
                dbcmd.CommandText = sql;
                reader = dbcmd.ExecuteReader();
                Client client;
                int i=0;
                while(reader.Read()) {
                    client=new Client((int)reader["id"],(string)reader["name"],(string)reader["surname1"],(string)reader["surname2"]);
                    searchResult.Add(i++,client);
                    Console.WriteLine(client.nomComplet());
                }
                if (i>0) {
                    Console.WriteLine("Client finded");
                    ClientWindow cw = new ClientWindow (dbcon,searchResult);
                    cw.Show ();
                    Console.WriteLine("Client finded 2");
                    this.Destroy();
                }
                reader.Close();

                } catch (Exception ex) {
                Console.WriteLine("ClientSearch: "+ex.Message);
                reader.Close();
            }
        }
开发者ID:BackupTheBerlios,项目名称:gadpime-svn,代码行数:32,代码来源:ClientSearchWindow.cs

示例3: BulkCopyAllEmployees

        // Add your own data access methods.
        // This file should not get overridden
        /// <summary>
        /// Executes the BulkCopy process to load Employee Information from IVantage to a local Table
        /// </summary>
        /// <param name="allEmployees">IDataReader that contains all Employees loaded from IVantage</param>
        public void BulkCopyAllEmployees(IDataReader allEmployees)
        {
            try
            {
                Database db = DatabaseFactory.CreateDatabase("OneSourceConnectionString");
                db.ExecuteNonQuery(CommandType.Text, "truncate table CS_Employee_Load");
            }
            catch (Exception ex)
            {
                allEmployees.Close(); // Close DataReader when an exception occurs
                throw new Exception("An error ocurred while truncating data from Employee Info (load).", ex);
            }

            string connString = ConfigurationManager.ConnectionStrings["OneSourceConnectionString"].ConnectionString;
            using (SqlBulkCopy copy = new SqlBulkCopy(connString))
            {
                try
                {
                    copy.DestinationTableName = "CS_Employee_Load";
                    copy.BulkCopyTimeout = 600;
                    copy.WriteToServer(allEmployees);
                }
                catch (Exception ex)
                {
                    throw new Exception("An error ocurred when importing Employee Info (BulkCopy).", ex);
                }
                finally
                {
                    allEmployees.Close();
                }
            }
        }
开发者ID:danilocecilia,项目名称:HulcherProject,代码行数:38,代码来源:CS_EmployeeRepository.cs

示例4: GetPhotoInfo

 public static PhotoInfo GetPhotoInfo(IDataReader reader)
 {
     if (reader.Read())
     {
         PhotoInfo pi = GetPhotoEntity(reader);
         reader.Close();
         return pi;
     }
     else
     {
         reader.Close();
         return null;
     }
 }
开发者ID:Vinna,项目名称:DeepInSummer,代码行数:14,代码来源:DTOProvider.cs

示例5: LoadListFromReader

 public static List<MonHoc> LoadListFromReader(IDataReader reader)
 {
     List<MonHoc> items = new List<MonHoc>();
     try
     {
         while (reader.Read())
         {
             MonHoc item = new MonHoc();
             try { item.MonHocGuid = new Guid(reader["MonHocGuid"].ToString()); }
             catch { }
             item.MonHocName = reader["MonHocName"].ToString();
             item.MonHocID = reader["MonHocID"].ToString();
             try { item.Userid = Convert.ToInt32(reader["Userid"].ToString()); }
             catch { }
             items.Add(item);
         }
     }
     catch
     { }
     finally
     {
         reader.Close();
     }
     return items;
 }
开发者ID:tsandtm,项目名称:BOEdu,代码行数:25,代码来源:MonHocDTO.cs

示例6: closeReader

 /// <summary>
 /// Readerをcloseします。
 /// </summary>
 /// <param name="reader">close対象のreader</param>
 protected void closeReader(IDataReader reader)
 {
     if (reader != null && !reader.IsClosed)
     {
         reader.Close();
     }
 }
开发者ID:ryozo,项目名称:scope,代码行数:11,代码来源:AbstractDao.cs

示例7: FillFolderPermissionInfoList

 private static ArrayList FillFolderPermissionInfoList(IDataReader dr)
 {
     ArrayList arr = new ArrayList();
     try
     {
         while (dr.Read())
         {
             // fill business object
             FolderPermissionInfo obj = FillFolderPermissionInfo(dr, false);
             // add to collection
             arr.Add(obj);
         }
     }
     catch (Exception exc)
     {
         Exceptions.LogException(exc);
     }
     finally
     {
         // close datareader
         if (dr != null)
         {
             dr.Close();
         }
     }
     return arr;
 }
开发者ID:huayang912,项目名称:cs-dotnetnuke,代码行数:27,代码来源:FolderPermissionController.cs

示例8: GetCategoryListEntity

 public static List<CategoryInfo> GetCategoryListEntity(IDataReader reader)
 {
     List<CategoryInfo> categorylist = new List<CategoryInfo>();
     while (reader.Read())
     {
         CategoryInfo cinfo = new CategoryInfo();
         cinfo.Cid = TypeConverter.ObjectToInt(reader["cid"], 0);
         cinfo.Name = reader["name"].ToString();
         cinfo.Parentid = TypeConverter.ObjectToInt(reader["parentid"].ToString(), 0);
         cinfo.Parentlist = reader["parentlist"].ToString();
         cinfo.Cg_img = reader["cg_img"].ToString();
         cinfo.Sort = TypeConverter.ObjectToInt(reader["sort"].ToString(), 0);
         cinfo.Cg_prefix = reader["cg_prefix"].ToString();
         cinfo.Cg_status = TypeConverter.ObjectToInt(reader["cg_status"].ToString(), 0);
         cinfo.Displayorder = TypeConverter.ObjectToInt(reader["displayorder"].ToString(), 0);
         cinfo.Haschild = reader["haschild"].ToString() == "True" ? 1 : 0;
         cinfo.Cg_relatetype = reader["cg_relatetype"].ToString();
         cinfo.Cg_relateclass = reader["cg_relateclass"].ToString();
         cinfo.Cg_relatebrand = reader["cg_relatebrand"].ToString();
         cinfo.Cg_desc = reader["cg_desc"].ToString();
         cinfo.Cg_keyword = reader["cg_keyword"].ToString();
         cinfo.Goodcount = TypeConverter.ObjectToInt(reader["goodcount"].ToString(), 0);
         categorylist.Add(cinfo);
     }
     reader.Close();
     return categorylist;
 }
开发者ID:yeyong,项目名称:manageserver,代码行数:27,代码来源:DTOProvider.cs

示例9: CloseDataReader

        internal static void CloseDataReader( IDataReader rd )
        {
            if (rd == null) return;
            if (rd.IsClosed) return;

            rd.Close();
        }
开发者ID:991899783,项目名称:BookShop,代码行数:7,代码来源:OrmUtil.cs

示例10: PopulateObjectWithJoinCustom

        /// <summary>
        /// Takes an prepopulated IDataReader and creates an array of ChatMessages
        /// </summary>
        public static List<ChatMessage> PopulateObjectWithJoinCustom(IDataReader dr)
        {
            ColumnFieldList list = new ColumnFieldList(dr);

            List<ChatMessage> arr = new List<ChatMessage>();

            ChatMessage obj;

            while (dr.Read())
            {
                obj = new ChatMessage();
                if (list.IsColumnPresent("ChatMessageID")) { obj._chatMessageID = (int)dr["ChatMessageID"]; }
                if (list.IsColumnPresent("ChatMessageWebID")) { obj._chatMessageWebID = (string)dr["ChatMessageWebID"]; }
                if (list.IsColumnPresent("MemberIDFrom")) { obj._memberIDFrom = (int)dr["MemberIDFrom"]; }
                if (list.IsColumnPresent("MemberIDTo")) { obj._memberIDTo = (int)dr["MemberIDTo"]; }
                if (list.IsColumnPresent("Message")) { obj._message = (string)dr["Message"]; }
                if (list.IsColumnPresent("Delivered")) { obj._delivered = (bool)dr["Delivered"]; }
                if (list.IsColumnPresent("DTCreated")) { obj._dTCreated = (DateTime)dr["DTCreated"]; }
                if (list.IsColumnPresent("WebMemberIDFrom")) { obj.WebMemberIDFrom = (String)dr["WebMemberIDFrom"]; }

                
                arr.Add(obj);
            }

            dr.Close();

            return arr;
        }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:31,代码来源:ChatMessage.cs

示例11: FillTabPermissionCollection

 private TabPermissionCollection FillTabPermissionCollection( IDataReader dr )
 {
     TabPermissionCollection arr = new TabPermissionCollection();
     try
     {
         TabPermissionInfo obj = null;
         while( dr.Read() )
         {
             // fill business object
             obj = FillTabPermissionInfo( dr, false );
             // add to collection
             arr.Add( obj );
         }
     }
     catch( Exception exc )
     {
         Exceptions.LogException( exc );
     }
     finally
     {
         // close datareader
         if( dr != null )
         {
             dr.Close();
         }
     }
     return arr;
 }
开发者ID:huayang912,项目名称:cs-dotnetnuke,代码行数:28,代码来源:TabPermissionController.cs

示例12: InMemoryDataReader

        /// <summary>
        ///  Creates an InMemoryDataReader from a <see cref="IDataReader" />
        /// </summary>
        /// <param name="reader">The <see cref="IDataReader" /> which holds the records from the Database.</param>
        public InMemoryDataReader(IDataReader reader)
        {
            ArrayList resultList = new ArrayList();

            try
            {
                _currentResultIndex = 0;
                _currentRowIndex = 0;

                resultList.Add( new InMemoryResultSet( reader, true ) );

                while( reader.NextResult() )
                {
                    resultList.Add( new InMemoryResultSet( reader, false ) );
                }

                _results = ( InMemoryResultSet[ ] ) resultList.ToArray( typeof( InMemoryResultSet ) );
            }
            catch( Exception e )
            {
                throw new DataMapperException( "There was a problem converting an IDataReader to an InMemoryDataReader", e );
            }
            finally
            {
                reader.Close();
                reader.Dispose();
            }
        }
开发者ID:hejiquan,项目名称:iBATIS_2010,代码行数:32,代码来源:InMemoryDataReader.cs

示例13: Start

    // Use this for initialization
    void Start()
    {
        OpenDB("MakingTime.db");
       _dbcm = _dbc.CreateCommand();
      
        //Insert data 
        sqlQuery = "INSERT INTO Event (name,current_day,current_time,min_day,max_day,min_time,max_time,scheduled,creator,type) VALUES ('Date',1,1,0,3,2,3,1,'Robert','Social')";
        _dbcm.CommandText = sqlQuery;
        _dbcm.ExecuteNonQuery();

        sqlQuery = "INSERT INTO Event (name,current_day,current_time,min_day,max_day,min_time,max_time,scheduled,creator,type) VALUES ('Party',1,1,0,3,2,3,1,'Gina','Social')";
        _dbcm.CommandText = sqlQuery;
        _dbcm.ExecuteNonQuery();

        sqlQuery = "INSERT INTO Event (name,current_day,current_time,min_day,max_day,min_time,max_time,scheduled,creator,type) VALUES ('Movie',1,1,0,3,2,3,1,'Robert','Social')";
        _dbcm.CommandText = sqlQuery;
        _dbcm.ExecuteNonQuery();

        sqlQuery = "select * from Event";
        _dbcm.CommandText = sqlQuery;
        _dbr = _dbcm.ExecuteReader();

        while (_dbr.Read())
        {
            Debug.Log("****** Data: " + _dbr["name"] + "\tday: " + _dbr["current_day"] + "\tTime: " + _dbr["current_time"] + "\tMin Day: " + _dbr["min_day"]
                + "\tMax Day: " + _dbr["max_day"] + "\tMin Time: " + _dbr["min_time"] + "\tMax Time: " + _dbr["max_time"] + "\tScheduled: " + _dbr["scheduled"]
                + "\tcreator: " + _dbr["creator"] + "\ttype: " + _dbr["type"]);
        }
        _dbr.Close();
        _dbr = null;
        _dbcm.Dispose();
        _dbcm = null;
        _dbc.Close();
        _dbc = null;
    }
开发者ID:BernardoOM,项目名称:Making-Time,代码行数:36,代码来源:DBMakingTime.cs

示例14: DataReaderToDataSet

        public static DataSet DataReaderToDataSet(IDataReader reader)
        {
            var ds = new DataSet();
            DataTable table;
            do
            {
                int fieldCount = reader.FieldCount;
                table = new DataTable();
                for (int i = 0; i < fieldCount; i++)
                {
                    table.Columns.Add(reader.GetName(i), reader.GetFieldType(i));
                }
                table.BeginLoadData();
                var values = new Object[fieldCount];
                while (reader.Read())
                {
                    reader.GetValues(values);
                    table.LoadDataRow(values, true);
                }
                table.EndLoadData();

                ds.Tables.Add(table);

            } while (reader.NextResult());
            reader.Close();
            return ds;
        }
开发者ID:samnuriu13,项目名称:APIXERP,代码行数:27,代码来源:Util.cs

示例15: ReadRandomNewCommitment

	public static void ReadRandomNewCommitment(string event_Type, ref string name, ref int time_Length,
	                                           ref int maxTime, ref int minTime)
	{
		OpenDB("MakingTime.db");
		_dbcm = _dbc.CreateCommand();

		sqlQuery = "select count(*) as NumberOfRegions from Event_Type where Category = '" + event_Type + "'";
		_dbcm.CommandText = sqlQuery;
		Int32 rows = Convert.ToInt32(_dbcm.ExecuteScalar());

		sqlQuery = "select * from Event_Type where Category = '" + event_Type + "'";
		_dbcm.CommandText = sqlQuery;
		_dbr = _dbcm.ExecuteReader();

		int commitmentRow = UnityEngine.Random.Range(0, rows);
		//Question 
		for(int countRows = 0; countRows < commitmentRow + 1; countRows += 1)
		{	
			_dbr.Read();	
		}

		name = _dbr.GetString(0);
		time_Length = _dbr.GetInt32(1);
		maxTime = _dbr.GetInt32(8);
		minTime = _dbr.GetInt32(7);

		_dbr.Close();
		_dbr = null;
		_dbcm.Dispose();
		_dbcm = null;
		_dbc.Close();
		_dbc = null;
	}
开发者ID:BernardoOM,项目名称:Making-Time,代码行数:33,代码来源:DBMakingTime.cs


注:本文中的IDataReader.Close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。