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


C# SqlDataReader.GetDateTime方法代码示例

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


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

示例1: LoadFromDataReader

        /// <summary>
        /// Loads the entity from a <b>SqlDataReader</b> object.
        /// </summary>
        /// <param name="dr">The data reader to read from.</param>
        /// <returns>Returns the number of columns read.</returns>
        /// <remarks>
        /// Always reads at the current cursor position, doesn't calls the <b>Read</b> function
        /// on the <b>SqlDataReader</b> object. Reads data columns by their ordinal position in
        /// the query and not by their names.
        /// </remarks>
        internal override int LoadFromDataReader(SqlDataReader dr)
        {
            int o = base.LoadFromDataReader(dr);

            ++o;    // skip guid
            this.workflowTypeName = dr.GetString(++o);
            this.dateStarted = dr.IsDBNull(++o) ? DateTime.MinValue : dr.GetDateTime(o);
            this.dateFinished = dr.IsDBNull(++o) ? DateTime.MinValue : dr.GetDateTime(o);
            this.jobExecutionStatus = (JobExecutionState)dr.GetInt32(++o);
            this.suspendTimeout = dr.IsDBNull(++o) ? DateTime.MinValue : dr.GetDateTime(o);
            this.scheduleType = (ScheduleType)dr.GetInt32(++o);
            this.scheduleTime = dr.IsDBNull(++o) ? DateTime.MinValue : dr.GetDateTime(o);
            this.recurringPeriod = (RecurringPeriod)dr.GetInt32(++o);
            this.recurringInterval = dr.GetInt32(++o);
            this.recurringMask = dr.GetInt64(++o);
            this.workflowInstanceId = dr.IsDBNull(++o) ? Guid.Empty : dr.GetGuid(o);
            this.adminRequestTime = dr.IsDBNull(++o) ? DateTime.MinValue : dr.GetDateTime(o);
            if (!dr.IsDBNull(++o))
            {
                XmlSerializer ser = new XmlSerializer(typeof(JobAdminRequestData));
                StringReader sr = new StringReader(dr.GetString(o));
                this.adminRequestData = (JobAdminRequestData)ser.Deserialize(sr);
            }
            else
            {
                this.adminRequestData = null;
            }
            this.adminRequestResult = dr.GetInt32(++o);
            this.exceptionMessage = dr.IsDBNull(++o) ? null : dr.GetString(o);

            return o;
        }
开发者ID:horvatferi,项目名称:graywulf,代码行数:42,代码来源:JobInstance.io.cs

示例2: ProcessSqlResult

 protected override Exception ProcessSqlResult(SqlDataReader reader)
 {
     Exception nextResultSet = StoreUtilities.GetNextResultSet(base.InstancePersistenceCommand.Name, reader);
     if (nextResultSet == null)
     {
         bool flag = !reader.IsDBNull(1);
         TimeSpan? taskIntervalOverride = null;
         bool flag2 = false;
         if (flag)
         {
             DateTime dateTime = reader.GetDateTime(1);
             DateTime time2 = reader.GetDateTime(2);
             if (dateTime <= time2)
             {
                 flag2 = true;
             }
             else
             {
                 taskIntervalOverride = new TimeSpan?(dateTime.Subtract(time2));
             }
         }
         if (flag2)
         {
             base.Store.UpdateEventStatus(true, InstancePersistenceEvent<HasRunnableWorkflowEvent>.Value);
             return nextResultSet;
         }
         base.Store.UpdateEventStatus(false, InstancePersistenceEvent<HasRunnableWorkflowEvent>.Value);
         base.StoreLock.InstanceDetectionTask.ResetTimer(false, taskIntervalOverride);
     }
     return nextResultSet;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:31,代码来源:DetectRunnableInstancesAsyncResult.cs

示例3: DataToModel

        /// <summary>
        /// 数据转用户实体
        /// </summary>
        public static UserInfo DataToModel(SqlDataReader rdr)
        {
            UserInfo user = new UserInfo();
            if (!rdr.IsDBNull(0)) user.UserID = rdr.GetInt32(0);
            if (!rdr.IsDBNull(1)) user.UserName = rdr.GetString(1);
            if (!rdr.IsDBNull(2)) user.UserPassword = rdr.GetString(2);
            if (!rdr.IsDBNull(3)) user.UserNickName = rdr.GetString(3);
            if (!rdr.IsDBNull(4)) user.UserImage = rdr.GetString(4);
            if (!rdr.IsDBNull(5)) user.UserPhone = rdr.GetString(5);
            if (!rdr.IsDBNull(6)) user.UserEmail = rdr.GetString(6);
            if (!rdr.IsDBNull(7)) user.UserTheme = rdr.GetString(7);
            if (!rdr.IsDBNull(8)) user.UserLevel = rdr.GetByte(8);
            if (!rdr.IsDBNull(9)) user.UserFrom = rdr.GetString(9);
            if (!rdr.IsDBNull(10)) user.ModifyDate = rdr.GetDateTime(10);
            if (!rdr.IsDBNull(11)) user.CreateDate = rdr.GetDateTime(11);
            if (!rdr.IsDBNull(12)) user.UserCity = rdr.GetString(12);
            if (!rdr.IsDBNull(13)) user.UserMoney = rdr.GetDecimal(13);
            if (!rdr.IsDBNull(14)) user.UserWorkDay = rdr.GetString(14);
            if (!rdr.IsDBNull(15)) user.UserFunction = rdr.GetString(15);
            if (!rdr.IsDBNull(16)) user.CategoryRate = rdr.GetInt32(16);
            if (!rdr.IsDBNull(17)) user.Synchronize = rdr.GetByte(17);
            if (!rdr.IsDBNull(18)) user.MoneyStart = rdr.GetDecimal(18);
            if (!rdr.IsDBNull(19)) user.IsUpdate = rdr.GetByte(19);

            return user;
        }
开发者ID:pyfxl,项目名称:fxlweb,代码行数:29,代码来源:UserTableDAL.cs

示例4: CrearUsuario

        private UsuarioEntity CrearUsuario(SqlDataReader cursor)
        {
            UsuarioEntity usuario = new UsuarioEntity();
            usuario.Id = cursor.GetInt32(cursor.GetOrdinal("UsuarioID"));
            usuario.Nombre = cursor.GetString(cursor.GetOrdinal("UsuarioNombre"));
            usuario.Perfil =char.Parse( cursor.GetValue(cursor.GetOrdinal("UsuarioPerfil")).ToString());
            usuario.Email = cursor.GetString(cursor.GetOrdinal("UsuarioEmail"));
            usuario.Password = cursor.GetString(cursor.GetOrdinal("UsuarioPassword"));
            usuario.Provincia = cursor.GetString(cursor.GetOrdinal("UsuarioProvincia"));
            usuario.Ciudad = cursor.GetString(cursor.GetOrdinal("UsuarioCiudad"));

            if (!cursor.IsDBNull(cursor.GetOrdinal("UsuarioFoto")))
                usuario.Foto = cursor.GetString(cursor.GetOrdinal("UsuarioFoto"));

            usuario.FechaRegistracion = cursor.GetDateTime(cursor.GetOrdinal("UsuarioFechaRegistracion"));

            if (!cursor.IsDBNull(cursor.GetOrdinal("UsuarioFechaActualizacion")))
                usuario.FechaActualizacion = cursor.GetDateTime(cursor.GetOrdinal("UsuarioFechaActualizacion"));

            switch (usuario.Perfil)
            {
                case 'M': usuario.musico = new MusicoEntity();
                    usuario.musico.FechaNacimiento = cursor.GetDateTime(cursor.GetOrdinal("UsuarioFechaNacimiento"));
                    usuario.musico.Genero = cursor.GetString(cursor.GetOrdinal("UsuarioGenero"));
                    if (!cursor.IsDBNull(cursor.GetOrdinal("CuentaYoutube")))
                        usuario.musico.CuentaYoutube = cursor.GetString(cursor.GetOrdinal("CuentaYoutube"));

                    if (!cursor.IsDBNull(cursor.GetOrdinal("CuentaFacebook")))
                        usuario.musico.CuentaFacebook = cursor.GetString(cursor.GetOrdinal("CuentaFacebook"));

                    if (!cursor.IsDBNull(cursor.GetOrdinal("CuentaSoundCloud")))
                        usuario.musico.CuentaSoundCloud = cursor.GetString(cursor.GetOrdinal("CuentaSoundCloud"));

                    if (!cursor.IsDBNull(cursor.GetOrdinal("CuentaTwitter")))
                        usuario.musico.CuentaTwitter = cursor.GetString(cursor.GetOrdinal("CuentaTwitter"));
                    break;

                default: usuario.lugar = new LugarEntity();
                    usuario.lugar.DirCalle = cursor.GetString(cursor.GetOrdinal("DirCalle"));
                    usuario.lugar.DirNumero = cursor.GetInt32(cursor.GetOrdinal("DirNro"));

                    if (!cursor.IsDBNull(cursor.GetOrdinal("HorarioDesde")))
                        usuario.lugar.HorarioDesde = cursor.GetString(cursor.GetOrdinal("HorarioDesde"));

                    if (!cursor.IsDBNull(cursor.GetOrdinal("HorarioHasta")))
                        usuario.lugar.HorarioHasta = cursor.GetString(cursor.GetOrdinal("HorarioHasta"));
                    break;
            }

            return usuario;
        }
开发者ID:krueff,项目名称:redsocial,代码行数:51,代码来源:UsuarioDA.cs

示例5: Factory

        public static NewMemberBalancePrediction Factory(SqlDataReader reader)
        {
            var newMemberId = reader.GetInt32(0);
            var dependentId = reader.GetInt32(1);
            var birthYear = reader.GetInt32(2);
            var state = reader.GetString(3);
            var lastCptCode = reader.GetString(4);
            var cachedBalance = reader.GetString(5);
            var recommendedBalance = reader.GetValue(6);

            double d;
            double.TryParse(recommendedBalance == null ? "0" : recommendedBalance.ToString(), out d);
            var sufficientAmount = reader.GetInt32(7);
            var serviceEnd = reader.GetDateTime(8);

            return new NewMemberBalancePrediction
                       {
                           NewMemberId = newMemberId,
                                 DependentId = dependentId,
                                 BirthYear = birthYear,
                                 State = state,
                                 LastCptCode = lastCptCode,
                                 CachedBalance = cachedBalance,
                                 RecommendedBalance = Math.Round(d, 2),
                                 SufficientAmount = sufficientAmount,
                                 ServiceEnd = serviceEnd
                       };
        }
开发者ID:roylanceMichael,项目名称:Health_Equity_Claims_Machine_Learning,代码行数:28,代码来源:NewMemberBalancePrediction.cs

示例6: GetTimeTolive

        private static TimeSpan GetTimeTolive(SqlDataReader dataReader)
        {
            if (dataReader.IsDBNull(TimeToLiveIndex))
            {
                return TimeSpan.MaxValue;
            }

            DateTime expireDateTime = dataReader.GetDateTime(TimeToLiveIndex);

            if (dataReader.GetDateTime(TimeToLiveIndex) < DateTime.UtcNow)
            {
                return TimeSpan.Zero;
            }

            return TimeSpan.FromTicks(expireDateTime.Ticks - DateTime.UtcNow.Ticks);
        }
开发者ID:kehinze,项目名称:Hermes,代码行数:16,代码来源:SqlMessageDequeStrategy.cs

示例7: RoadMap

        public RoadMap(string name )
        {
            mName = name;

            mDatabase.connect();
            mReader = mDatabase.executeread("SELECT Timestamp, Description, UserID FROM [dbo].[Roadmap] WHERE Name = '" + name + "'");
            mReader.Read();

            mTimeStamp = mReader.GetDateTime(0);
            mDescription = mReader.GetString(1);
            string UID = mReader.GetString(2);

            mDatabase.close();

            mDatabase.connect();
            mReader = mDatabase.executeread("SELECT Name, Email, Password FROM [dbo].[User] WHERE ID = '" + UID + "'");
            mReader.Read();

            mUser = new User(mReader.GetString(0), UID, mReader.GetString(1), mReader.GetString(2));

            mDatabase.close();

            mTimeline = new TimeLine(mName);

            //Get the StrategyPoints
            mDatabase.connect();
            mReader = mDatabase.executeread("SELECT Name, Description FROM [dbo].[StrategyPoint] WHERE RoadmapName = '" + name + "'");
            while (mReader.Read())
            {
                StrategyPoint sp = new StrategyPoint(mReader.GetString(0), mReader.GetString(1));
                mStrategyPoints.Add(sp);
            }
            mDatabase.close();
        }
开发者ID:grovecha,项目名称:RocketRoadmap,代码行数:34,代码来源:RoadMap.cs

示例8: ValidateDataReader_T

 public static DateTime ValidateDataReader_T(SqlDataReader reader,string colname)
 {
     if(reader.GetValue(reader.GetOrdinal(colname))!=DBNull.Value)
         return reader.GetDateTime(reader.GetOrdinal(colname));
     else
         return System.DateTime.MinValue;
 }
开发者ID:JohnToCoder,项目名称:MyBookShop_1,代码行数:7,代码来源:GetSafeData.cs

示例9: GetModelBySDR

 /// <summary>
 /// 根据sqldatareader进行获取模型
 /// </summary>
 /// <param name="sdr"></param>
 /// <returns></returns>
 public T_Member GetModelBySDR(SqlDataReader sdr)
 {
     T_Member t_m = null;
     if (sdr.Read())
     {
         t_m = new T_Member();
         t_m.F_Id = sdr.GetInt32(0);
         t_m.F_Email = sdr.GetString(1);
         t_m.F_Password = sdr.GetString(2);
         t_m.F_Sex = sdr.GetBoolean(3);
         t_m.F_NickName = sdr.GetString(4);
         t_m.F_Headpic = sdr.GetString(5);
         t_m.F_SecurityPassWord = sdr.GetString(6);
         t_m.F_Alipay = sdr.GetString(7);
         t_m.F_Issues = sdr.GetString(8);
         t_m.F_Answer = sdr.GetString(9);
         t_m.F_InitPassWord = sdr.GetString(10);
         t_m.F_Mobile = sdr.GetString(11);
         t_m.F_QQ = sdr.GetString(12);
         t_m.F_Level = sdr.GetInt32(13);
         t_m.F_Gold = sdr.GetInt32(14);
         t_m.F_Diamond = sdr.GetInt32(15);
         t_m.F_VIP = sdr.GetBoolean(16);
         t_m.F_KEY = sdr.GetString(17);
         t_m.F_Status = sdr.GetInt32(18);
         t_m.F_CreateDate = sdr.GetDateTime(19);
     }
     return t_m;
 }
开发者ID:cj1324,项目名称:hanchenproject,代码行数:34,代码来源:Manage_T_Member.cs

示例10: getComments

 public int getComments(int id, out List<string> name, out List<DateTime> date, out List<string> comments)
 {
     name = new List<string>();
     date = new List<DateTime>();
     comments = new List<string>();
     cmd.CommandText = "SELECT * FROM comment where id=" + id.ToString() + " ORDER BY comdate DESC";
     try
     {
         SqlInit();
         dr = cmd.ExecuteReader();
         while (dr.Read())
         {
             name.Add(dr.GetString(1));
             date.Add(dr.GetDateTime(2));
             comments.Add(dr.GetString(3));
         }
     }
     catch(SqlException e)
     {
         SqlExit();
         return 666;
     }
     if (name.Count == 0)
     {
         SqlExit();
         return 1;//no comments
     }
     SqlExit();
     return 0;//success
 }
开发者ID:Fighting-ZhangZhao,项目名称:MicroZone,代码行数:30,代码来源:Supports.cs

示例11: SafeGetDate

 /**
  * Descripción: Obtiene el campo fecha de la tabla de forma segura (revisando si es null o no antes de leerlo)
  * Recibe un SqlDataReader con el que se obtiene el campo y el índice de la columna a consultar
  * Devuelve un valor DateTime dependiendo del resultado de la consulta. La fecha actual si el campo está nulo
  */
 public static DateTime SafeGetDate(SqlDataReader reader, int colIndex)
 {
     if (!reader.IsDBNull(colIndex))
         return reader.GetDateTime(colIndex);
     else
         return DateTime.Now;
 }
开发者ID:ProyInge,项目名称:ProyectoInge,代码行数:12,代码来源:ControladoraBDRH.cs

示例12: FillCategory

 private Category FillCategory(SqlDataReader reader)
 {
     var author = new Category();
     author.Id = reader.GetInt32(0);
     author.Name = reader.GetString(1);           
     author.DateCreated = reader.GetDateTime(2);
     return author;
 }
开发者ID:jordiruiz,项目名称:Joomiz.Blog,代码行数:8,代码来源:CategoryRepository.cs

示例13: LoadEntity

 protected override DomainObject LoadEntity(int Id, SqlDataReader res)
 {
     Ilan ilan = new Ilan(Id);
     if (res.Read())
     {
         string kur = res.GetString(4);
         int ilanFiyat = res.GetInt32(3);
         DateTime basTarih = res.GetDateTime(1);
         DateTime bitTarih = res.GetDateTime(2);
         IlanSuresi _ilanSuresi = new IlanSuresi(basTarih,bitTarih);
         Fiyat _ilanFiyat = new Fiyat(ilanFiyat,kur);
         ilan.IlanAdi = res.GetString(5);
         ilan.IlanFiyat = _ilanFiyat;
         ilan.IlanSuresi = _ilanSuresi;
     }
     return ilan;
 }
开发者ID:erdonet,项目名称:EnterpriseDesignPatterns,代码行数:17,代码来源:IlanMapper.cs

示例14: DataToModel

        /// <summary>
        /// 数据转转账实体
        /// </summary>
        public static ZhuanZhangInfo DataToModel(SqlDataReader rdr)
        {
            ZhuanZhangInfo zhang = new ZhuanZhangInfo();
            if (!rdr.IsDBNull(0)) zhang.ZhuanZhangID = rdr.GetInt32(0);
            if (!rdr.IsDBNull(1)) zhang.ZhuanZhangFrom = rdr.GetInt32(1);
            if (!rdr.IsDBNull(2)) zhang.ZhuanZhangTo = rdr.GetInt32(2);
            if (!rdr.IsDBNull(3)) zhang.ZhuanZhangDate = rdr.GetDateTime(3);
            if (!rdr.IsDBNull(4)) zhang.ZhuanZhangMoney = rdr.GetDecimal(4);
            if (!rdr.IsDBNull(5)) zhang.ZhuanZhangLive = rdr.GetByte(5);
            if (!rdr.IsDBNull(7)) zhang.Synchronize = rdr.GetByte(6);
            if (!rdr.IsDBNull(6)) zhang.ModifyDate = rdr.GetDateTime(7);
            if (!rdr.IsDBNull(7)) zhang.UserID = rdr.GetInt32(8);
            if (!rdr.IsDBNull(7)) zhang.ZhuanZhangNote = rdr.GetString(9);
            if (!rdr.IsDBNull(7)) zhang.ZZID = rdr.GetInt32(10);

            return zhang;
        }
开发者ID:pyfxl,项目名称:fxlweb,代码行数:20,代码来源:ZhuanZhangTableDAL.cs

示例15: PrepareListModel

 public void PrepareListModel(SqlDataReader dr, List<TableBaseInfo> infoList)
 {
     while (dr.Read())
     {
         TableBaseInfo info = new TableBaseInfo();
         info.ID = dr.GetInt32(0);
         info.TableName = dr[1].ToString();
         info.TableDescription = dr[2].ToString();
         info.Fields = dr[3].ToString();
         info.UserID = dr.GetInt32(4);
         info.UserName = dr[5].ToString();
         info.Status = dr.GetInt32(6);
         info.AddTime = dr.GetDateTime(7);
         info.UpdateTime = (dr[8] == DBNull.Value ? info.AddTime : dr.GetDateTime(8));
         info.MySysTableID = dr.GetInt32(9);
         infoList.Add(info);
     }
 }
开发者ID:guoxiongfei,项目名称:SearchBlog,代码行数:18,代码来源:TableDAL.cs


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