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


C# Database.ExecuteReader方法代码示例

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


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

示例1: Save

        public void Save(Database db)
        {
            DbCommand dbCommand = db.GetStoredProcCommand("AG_SaveMetadata");

            db.AddInParameter(dbCommand, "MetaDataID", DbType.Int32, MetaDataID);
            db.AddInParameter(dbCommand, "GeoNamesModDate", DbType.DateTime, GeoNamesModDate);

            using (IDataReader dr = db.ExecuteReader(dbCommand))
            {

                // get the returned ID
                if (dr.Read())
                {
                    int ID = Int32.Parse(dr[0].ToString());
                    //if the ID is NOT zero then the query was an insert
                    if (ID != 0)
                        this.MetaDataID = ID;
                }

                dr.Close();
            }
        }
开发者ID:AnthonyNystrom,项目名称:YoGoMee,代码行数:22,代码来源:AutoGenerated.cs

示例2: TimeZone

        /// <summary>
        /// Instanciates a TimeZone object from the database via the TimeZoneID
        /// </summary>
        public TimeZone(int TimeZoneID)
        {
            db = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("AG_GetTimeZoneByTimeZoneID");
            db.AddInParameter(dbCommand, "TimeZoneID", DbType.Int32, TimeZoneID);

            //execute the stored procedure
            using (IDataReader dr = db.ExecuteReader(dbCommand))
            {
                ColumnFieldList list = new ColumnFieldList(dr);

                if (dr.Read())
                {
                    if (list.IsColumnPresent("TimeZoneID")) { this._timeZoneID = (int)dr["TimeZoneID"]; }
                    if (list.IsColumnPresent("TimeZoneCD")) { this._timeZoneCD = (string)dr["TimeZoneCD"]; }
                    if (list.IsColumnPresent("GMTOffSet")) { this._gMTOffSet = (decimal)dr["GMTOffSet"]; }
                    if (list.IsColumnPresent("DSTOffSet")) { this._dSTOffSet = (decimal)dr["DSTOffSet"]; }

                }
                else
                {
                    throw new Exception("There is no TimeZone in the database with the ID " + TimeZoneID);
                }

                dr.Close();
            }
        }
开发者ID:AnthonyNystrom,项目名称:YoGoMee,代码行数:30,代码来源:AutoGenerated.cs

示例3: AvailableCustomFields

 private List<string> AvailableCustomFields(Database.DBCon db)
 {
     var result = new List<string>();
     var dr = db.ExecuteReader("select fname from CustomLocal");
     while (dr.Read())
     {
         result.Add(dr.GetString(0));
     }
     return result;
 }
开发者ID:Verturin,项目名称:GSAKWrapper,代码行数:10,代码来源:ActionCustomText.cs

示例4: Metadata

        /// <summary>
        /// Instanciates a Metadata object from the database via the MetaDataID
        /// </summary>
        public Metadata(int MetaDataID)
        {
            db = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("AG_GetMetadataByMetaDataID");
            db.AddInParameter(dbCommand, "MetaDataID", DbType.Int32, MetaDataID);

            //execute the stored procedure
            using (IDataReader dr = db.ExecuteReader(dbCommand))
            {
                ColumnFieldList list = new ColumnFieldList(dr);

                if (dr.Read())
                {
                    if (list.IsColumnPresent("MetaDataID")) { this._metaDataID = (int)dr["MetaDataID"]; }
                    if (list.IsColumnPresent("GeoNamesModDate")) { this._geoNamesModDate = (DateTime)dr["GeoNamesModDate"]; }

                }
                else
                {
                    throw new Exception("There is no Metadata in the database with the ID " + MetaDataID);
                }

                dr.Close();
            }
        }
开发者ID:AnthonyNystrom,项目名称:YoGoMee,代码行数:28,代码来源:AutoGenerated.cs

示例5: FeatureCode

        /// <summary>
        /// Instanciates a FeatureCode object from the database via the FeatureCodeID
        /// </summary>
        public FeatureCode(int FeatureCodeID)
        {
            db = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("AG_GetFeatureCodeByFeatureCodeID");
            db.AddInParameter(dbCommand, "FeatureCodeID", DbType.Int32, FeatureCodeID);

            //execute the stored procedure
            using (IDataReader dr = db.ExecuteReader(dbCommand))
            {
                ColumnFieldList list = new ColumnFieldList(dr);

                if (dr.Read())
                {
                    if (list.IsColumnPresent("FeatureCodeID")) { this._featureCodeID = (int)dr["FeatureCodeID"]; }
                    if (list.IsColumnPresent("FeatureCodeCD")) { this._featureCodeCD = (string)dr["FeatureCodeCD"]; }
                    if (list.IsColumnPresent("FeatureClassID")) { this._featureClassID = (int)dr["FeatureClassID"]; }
                    if (list.IsColumnPresent("Name")) { this._name = (string)dr["Name"]; }
                    if (list.IsColumnPresent("Description")) { this._description = (string)dr["Description"]; }

                }
                else
                {
                    throw new Exception("There is no FeatureCode in the database with the ID " + FeatureCodeID);
                }

                dr.Close();
            }
        }
开发者ID:AnthonyNystrom,项目名称:YoGoMee,代码行数:31,代码来源:AutoGenerated.cs

示例6: YoGomeeUser

        /// <summary>
        /// Instanciates a YoGomeeUser object from the database via the YoGomeeUserID
        /// </summary>
        public YoGomeeUser(int YoGomeeUserID)
        {
            db = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("AG_GetYoGomeeUserByYoGomeeUserID");
            db.AddInParameter(dbCommand, "YoGomeeUserID", DbType.Int32, YoGomeeUserID);

            //execute the stored procedure
            using (IDataReader dr = db.ExecuteReader(dbCommand))
            {
                ColumnFieldList list = new ColumnFieldList(dr);

                if (dr.Read())
                {
                    if (list.IsColumnPresent("YoGomeeUserID")) { this._yoGomeeUserID = (int)dr["YoGomeeUserID"]; }
                    if (list.IsColumnPresent("FirstName")) { this._firstName = (string)dr["FirstName"]; }
                    if (list.IsColumnPresent("LastName")) { this._lastName = (string)dr["LastName"]; }
                    if (list.IsColumnPresent("EmailAddress")) { this._emailAddress = (string)dr["EmailAddress"]; }
                    if (list.IsColumnPresent("Password")) { this._password = (string)dr["Password"]; }
                    if (list.IsColumnPresent("PhoneNumber")) { this._phoneNumber = (string)dr["PhoneNumber"]; }
                    if (list.IsColumnPresent("PhoneModel")) { this._phoneModel = (int)dr["PhoneModel"]; }
                    if (list.IsColumnPresent("ISOCountry")) { this._iSOCountry = (string)dr["ISOCountry"]; }
                    if (list.IsColumnPresent("SignupIPAddress")) { this._signupIPAddress = (string)dr["SignupIPAddress"]; }
                    if (list.IsColumnPresent("Created")) { this._created = (DateTime)dr["Created"]; }

                }
                else
                {
                    throw new Exception("There is no YoGomeeUser in the database with the ID " + YoGomeeUserID);
                }

                dr.Close();
            }
        }
开发者ID:AnthonyNystrom,项目名称:YoGoMee,代码行数:36,代码来源:AutoGenerated.cs

示例7: Gomee

        /// <summary>
        /// Instanciates a Gomee object from the database via the GomeeID
        /// </summary>
        public Gomee(int GomeeID)
        {
            db = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("AG_GetGomeeByGomeeID");
            db.AddInParameter(dbCommand, "GomeeID", DbType.Int32, GomeeID);

            //execute the stored procedure
            using (IDataReader dr = db.ExecuteReader(dbCommand))
            {
                ColumnFieldList list = new ColumnFieldList(dr);

                if (dr.Read())
                {
                    if (list.IsColumnPresent("GomeeID")) { this._gomeeID = (int)dr["GomeeID"]; }
                    if (list.IsColumnPresent("YoGomeeUserID")) { this._yoGomeeUserID = (int)dr["YoGomeeUserID"]; }
                    if (list.IsColumnPresent("Active")) { this._active = (bool)dr["Active"]; }
                    if (list.IsColumnPresent("Latitude")) { this._latitude = (decimal)dr["Latitude"]; }
                    if (list.IsColumnPresent("Longitude")) { this._longitude = (decimal)dr["Longitude"]; }
                    if (list.IsColumnPresent("Expiration")) { this._expiration = (DateTime)dr["Expiration"]; }
                    if (list.IsColumnPresent("DoesExpire")) { this._doesExpire = (bool)dr["DoesExpire"]; }
                    if (list.IsColumnPresent("GomeeType")) { this._gomeeType = (int)dr["GomeeType"]; }
                    if (list.IsColumnPresent("RawValue1")) { this._rawValue1 = (string)dr["RawValue1"]; }
                    if (list.IsColumnPresent("RawValue2")) { this._rawValue2 = (string)dr["RawValue2"]; }
                    if (list.IsColumnPresent("Created")) { this._created = (DateTime)dr["Created"]; }

                }
                else
                {
                    throw new Exception("There is no Gomee in the database with the ID " + GomeeID);
                }

                dr.Close();
            }
        }
开发者ID:AnthonyNystrom,项目名称:YoGoMee,代码行数:37,代码来源:AutoGenerated.cs

示例8: GeoName

        /// <summary>
        /// Instanciates a GeoName object from the database via the GeoNameID
        /// </summary>
        public GeoName(int GeoNameID)
        {
            db = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("AG_GetGeoNameByGeoNameID");
            db.AddInParameter(dbCommand, "GeoNameID", DbType.Int32, GeoNameID);

            //execute the stored procedure
            using (IDataReader dr = db.ExecuteReader(dbCommand))
            {
                ColumnFieldList list = new ColumnFieldList(dr);

                if (dr.Read())
                {
                    if (list.IsColumnPresent("GeoNameID")) { this._geoNameID = (int)dr["GeoNameID"]; }
                    if (list.IsColumnPresent("Name")) { this._name = (string)dr["Name"]; }
                    if (list.IsColumnPresent("Latitude")) { this._latitude = (decimal)dr["Latitude"]; }
                    if (list.IsColumnPresent("Longitude")) { this._longitude = (decimal)dr["Longitude"]; }
                    if (list.IsColumnPresent("FeatureClassID")) { this._featureClassID = (int)dr["FeatureClassID"]; }
                    if (list.IsColumnPresent("FeatureCodeID")) { this._featureCodeID = (int)dr["FeatureCodeID"]; }
                    if (list.IsColumnPresent("CountryID")) { this._countryID = (int)dr["CountryID"]; }
                    if (list.IsColumnPresent("Admin1ID")) { this._admin1ID = (int)dr["Admin1ID"]; }
                    if (list.IsColumnPresent("Population")) { this._population = (int)dr["Population"]; }
                    if (list.IsColumnPresent("Elevation")) { this._elevation = (int)dr["Elevation"]; }
                    if (list.IsColumnPresent("gtopo3")) { this._gtopo3 = (int)dr["gtopo3"]; }
                    if (list.IsColumnPresent("TimeZoneID")) { this._timeZoneID = (int)dr["TimeZoneID"]; }
                    if (list.IsColumnPresent("ModDate")) { this._modDate = (DateTime)dr["ModDate"]; }

                }
                else
                {
                    throw new Exception("There is no GeoName in the database with the ID " + GeoNameID);
                }

                dr.Close();
            }
        }
开发者ID:AnthonyNystrom,项目名称:YoGoMee,代码行数:39,代码来源:AutoGenerated.cs

示例9: Friend

        /// <summary>
        /// Instanciates a Friend object from the database via the FriendID
        /// </summary>
        public Friend(int FriendID)
        {
            db = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("AG_GetFriendByFriendID");
            db.AddInParameter(dbCommand, "FriendID", DbType.Int32, FriendID);

            //execute the stored procedure
            using (IDataReader dr = db.ExecuteReader(dbCommand))
            {
                ColumnFieldList list = new ColumnFieldList(dr);

                if (dr.Read())
                {
                    if (list.IsColumnPresent("FriendID")) { this._friendID = (int)dr["FriendID"]; }
                    if (list.IsColumnPresent("YoGomeeUserID1")) { this._yoGomeeUserID1 = (int)dr["YoGomeeUserID1"]; }
                    if (list.IsColumnPresent("YoGomeeUserID2")) { this._yoGomeeUserID2 = (int)dr["YoGomeeUserID2"]; }
                    if (list.IsColumnPresent("User1Accepted")) { this._user1Accepted = (bool)dr["User1Accepted"]; }
                    if (list.IsColumnPresent("User2Accepted")) { this._user2Accepted = (bool)dr["User2Accepted"]; }
                    if (list.IsColumnPresent("UnfriendedUserID")) { this._unfriendedUserID = (int)dr["UnfriendedUserID"]; }

                }
                else
                {
                    throw new Exception("There is no Friend in the database with the ID " + FriendID);
                }

                dr.Close();
            }
        }
开发者ID:AnthonyNystrom,项目名称:YoGoMee,代码行数:32,代码来源:AutoGenerated.cs

示例10: GomeeMap

        /// <summary>
        /// Instanciates a GomeeMap object from the database via the GomeeMapID
        /// </summary>
        public GomeeMap(int GomeeMapID)
        {
            db = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("AG_GetGomeeMapByGomeeMapID");
            db.AddInParameter(dbCommand, "GomeeMapID", DbType.Int32, GomeeMapID);

            //execute the stored procedure
            using (IDataReader dr = db.ExecuteReader(dbCommand))
            {
                ColumnFieldList list = new ColumnFieldList(dr);

                if (dr.Read())
                {
                    if (list.IsColumnPresent("GomeeMapID")) { this._gomeeMapID = (int)dr["GomeeMapID"]; }
                    if (list.IsColumnPresent("YoGomeeUserID")) { this._yoGomeeUserID = (int)dr["YoGomeeUserID"]; }
                    if (list.IsColumnPresent("GomeeID")) { this._gomeeID = (int)dr["GomeeID"]; }
                    if (list.IsColumnPresent("ProximityHit")) { this._proximityHit = (bool)dr["ProximityHit"]; }
                    if (list.IsColumnPresent("ProximityDateTime")) { this._proximityDateTime = (DateTime)dr["ProximityDateTime"]; }
                    if (list.IsColumnPresent("ReceivedGomee")) { this._receivedGomee = (bool)dr["ReceivedGomee"]; }
                    if (list.IsColumnPresent("ReceivedGomeeDateTime")) { this._receivedGomeeDateTime = (DateTime)dr["ReceivedGomeeDateTime"]; }

                }
                else
                {
                    throw new Exception("There is no GomeeMap in the database with the ID " + GomeeMapID);
                }

                dr.Close();
            }
        }
开发者ID:AnthonyNystrom,项目名称:YoGoMee,代码行数:33,代码来源:AutoGenerated.cs

示例11: Country

        /// <summary>
        /// Instanciates a Country object from the database via the CountryID
        /// </summary>
        public Country(int CountryID)
        {
            db = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("AG_GetCountryByCountryID");
            db.AddInParameter(dbCommand, "CountryID", DbType.Int32, CountryID);

            //execute the stored procedure
            using (IDataReader dr = db.ExecuteReader(dbCommand))
            {
                ColumnFieldList list = new ColumnFieldList(dr);

                if (dr.Read())
                {
                    if (list.IsColumnPresent("CountryID")) { this._countryID = (int)dr["CountryID"]; }
                    if (list.IsColumnPresent("CountryCode")) { this._countryCode = (string)dr["CountryCode"]; }
                    if (list.IsColumnPresent("Name")) { this._name = (string)dr["Name"]; }

                }
                else
                {
                    throw new Exception("There is no Country in the database with the ID " + CountryID);
                }

                dr.Close();
            }
        }
开发者ID:AnthonyNystrom,项目名称:YoGoMee,代码行数:29,代码来源:AutoGenerated.cs

示例12: ISOLanguage

        /// <summary>
        /// Instanciates a ISOLanguage object from the database via the ISOLanguageID
        /// </summary>
        public ISOLanguage(int ISOLanguageID)
        {
            db = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("AG_GetISOLanguageByISOLanguageID");
            db.AddInParameter(dbCommand, "ISOLanguageID", DbType.Int32, ISOLanguageID);

            //execute the stored procedure
            using (IDataReader dr = db.ExecuteReader(dbCommand))
            {
                ColumnFieldList list = new ColumnFieldList(dr);

                if (dr.Read())
                {
                    if (list.IsColumnPresent("ISOLanguageID")) { this._iSOLanguageID = (int)dr["ISOLanguageID"]; }
                    if (list.IsColumnPresent("ISO639_1")) { this._iSO639_1 = (string)dr["ISO639_1"]; }
                    if (list.IsColumnPresent("ISO639_2")) { this._iSO639_2 = (string)dr["ISO639_2"]; }
                    if (list.IsColumnPresent("ISO639_3")) { this._iSO639_3 = (string)dr["ISO639_3"]; }
                    if (list.IsColumnPresent("Name")) { this._name = (string)dr["Name"]; }

                }
                else
                {
                    throw new Exception("There is no ISOLanguage in the database with the ID " + ISOLanguageID);
                }

                dr.Close();
            }
        }
开发者ID:AnthonyNystrom,项目名称:YoGoMee,代码行数:31,代码来源:AutoGenerated.cs

示例13: GetGeoNameByFeatureClassID

        /// <summary>
        /// Calls the database and gets all the GeoName objects for this FeatureClass
        /// </summary>
        private List<GeoName> GetGeoNameByFeatureClassID()
        {
            db = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("AG_GetGeoNameByFeatureClassID");
            db.AddInParameter(dbCommand, "FeatureClassID", DbType.Int32, FeatureClassID);

            List<GeoName> arr = null;

            // Populate the datareader
            using (IDataReader dr = db.ExecuteReader(dbCommand))
            {
                // Call the PopulateObject method passing the datareader to return the object array
                arr = yoGomee.Data.GeoName.PopulateObject(dr);
                dr.Close();
            }

            return arr;
        }
开发者ID:AnthonyNystrom,项目名称:YoGoMee,代码行数:21,代码来源:AutoGenerated.cs

示例14: AvailableCustomFields

 protected List<string> AvailableCustomFields(Database.DBCon db)
 {
     var result = new List<string>();
     var dr = db.ExecuteReader("select fname from CustomLocal");
     while (dr.Read())
     {
         result.Add(dr.GetString(0));
     }
     result.AddRange((from a in ApplicationData.Instance.GSAKCustomGlobals select a.fname).ToArray());
     return result;
 }
开发者ID:GlobalcachingEU,项目名称:GSAKWrapper,代码行数:11,代码来源:ActionImplementation.cs

示例15: Start

        public void Start(Database database)
        {
            var lastArticle = database.ExecuteReader<Article>("SELECT * FROM Article ORDER BY ArticleId DESC LIMIT 1");
            if (lastArticle.Count == 0)
            {
                _lastCrawledArticleId = 0;
            }
            else
            {
                _lastCrawledArticleId = lastArticle[0].ArticleId;
            }

            var lastArticleId = GetLastArticleId();
            while (true)
            {
                // crawling 해야 할 글 지정
                var nextArticleId = _lastCrawledArticleId + 1;

                // 웹사이트 주소 구성
                var targetUrl = MakeArticleUrl(CategoryId, nextArticleId);

                try
                {

                    // 웹사이트 긁기 - 5초 이후 timeout
                    var rawHtml = targetUrl.CrawlIt(Encoding.GetEncoding(51949), 5000);

                    // 원하는 내용 추출
                    var htmlDoc = new HtmlDocument();
                    htmlDoc.LoadHtml(rawHtml);

                    var article = new Article
                    {
                        CategoryId = CategoryId,
                        ArticleId = nextArticleId,
                        RawHtml = rawHtml,
                        CrawlingTime = DateTime.Now,
                    };

                    article.IsDeleted = htmlDoc.IsDeletedArticle();
                    if (!article.IsDeleted)
                    {
                        article.Author = htmlDoc.ExtractAutor();
                        article.WriteTime = htmlDoc.ExtractWrittenTime();
                        article.Title = htmlDoc.ExtractTitle();
                        article.Content = htmlDoc.ExtractContent();
                    }

                    // 데이터베이스에 저장
                    database.SyncData<Article>(article);
                }
                catch (Exception ex)
                {
                    LogHelper.Log(new Exception(targetUrl));
                    LogHelper.Log(ex);
                }

                // 최신 글인지 확인
                while (nextArticleId == lastArticleId)
                {
                    lastArticleId = GetLastArticleId();
                    if (nextArticleId == lastArticleId)
                    {
                        // 글이 없을 경우 스레드 10분간 휴식
                        Thread.Sleep(10 * 60 * 1000);
                    }
                }

                // 각 글을 crawling 한 후 3초간 휴식
                Thread.Sleep(3 * 1000);

                _lastCrawledArticleId++;
            }
        }
开发者ID:WhiteCandy,项目名称:Crawler,代码行数:74,代码来源:InvenCrawler.cs


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