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


C# SqlDataReader.GetString方法代码示例

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


在下文中一共展示了SqlDataReader.GetString方法的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: MakeViewSeguridadUsuario

        /// <summary>
        /// Creates a new instance of the ViewSeguridadUsuario class and populates it with data from the specified SqlDataReader.
        /// </summary>
        private static ViewSeguridadUsuarioInfo MakeViewSeguridadUsuario(SqlDataReader dataReader)
        {
            ViewSeguridadUsuarioInfo viewSeguridadUsuario = new ViewSeguridadUsuarioInfo();

            if (dataReader.IsDBNull(SeguridadUsuarioId) == false)
                viewSeguridadUsuario.SeguridadUsuarioId = dataReader.GetInt32(SeguridadUsuarioId);
            if (dataReader.IsDBNull(SeguridadRolId) == false)
                viewSeguridadUsuario.SeguridadRolId = dataReader.GetInt32(SeguridadRolId);
            if (dataReader.IsDBNull(Rol) == false)
                viewSeguridadUsuario.Rol = dataReader.GetString(Rol);
            if (dataReader.IsDBNull(NombreUsuario) == false)
                viewSeguridadUsuario.NombreUsuario = dataReader.GetString(NombreUsuario);
            if (dataReader.IsDBNull(Nombres) == false)
                viewSeguridadUsuario.Nombres = dataReader.GetString(Nombres);
            if (dataReader.IsDBNull(Apellidos) == false)
                viewSeguridadUsuario.Apellidos = dataReader.GetString(Apellidos);
            if (dataReader.IsDBNull(PaswordHash) == false)
                viewSeguridadUsuario.PaswordHash = dataReader.GetString(PaswordHash);
            if (dataReader.IsDBNull(Salt) == false)
                viewSeguridadUsuario.salt = dataReader.GetString(Salt);
            if (dataReader.IsDBNull(Activo) == false)
                viewSeguridadUsuario.Activo = dataReader.GetBoolean(Activo);
            if (dataReader.IsDBNull(NombreCompleto) == false)
                viewSeguridadUsuario.NombreCompleto = dataReader.GetString(NombreCompleto);

            return viewSeguridadUsuario;
        }
开发者ID:Avaruz,项目名称:SGC,代码行数:30,代码来源:ViewSeguridadUsuarioDb.cs

示例3: btnSignIn_Click

 protected void btnSignIn_Click(object sender, ImageClickEventArgs e)
 {
     if (txtUsername.Text.Trim() == "" || txtPassword.Text.Trim() == "")
         lblMessage.Text = "Both fields are required";
     else
     {
         query = "select usertype from Login where username='" + txtUsername.Text + "' AND Password='" + txtPassword.Text + "'";
         reader = db.data_read(query);
         if (reader.Read())
         {
             if (reader.GetString(0).Trim() == "Employee") // Go to employee's home page
             {
                 Session["username"] = txtUsername.Text;
                 reader.Close();
                 Response.Redirect("~/employee/EmployeeHome.aspx");
             }
             else if (reader.GetString(0).Trim() == "Employer")// Go to employer's home page
             {
                 Session["username"] = txtUsername.Text;
                 reader.Close();
                 Response.Redirect("~/employer/EmployerHome.aspx");
             }
             else // Go to admin's home page
             {
                 Session["username"] = txtUsername.Text;
                 Response.Redirect("~/admin/Home.aspx");
             }
         }
         else
         {
             lblMessage.Text = "Invalid Username/Password or no such user exists";
         }
     }
 }
开发者ID:sandeshps,项目名称:VirtualCabin,代码行数:34,代码来源:Login.aspx.cs

示例4: Documents

 private Documents(SqlDataReader data)
 {
     ID = data.GetInt32(0);
     Name = data.GetString(1);
     hash = data.GetString(2);
     buffer = data.GetSqlBinary(3).Value;
 }
开发者ID:JackJCSN,项目名称:APMS,代码行数:7,代码来源:Documents.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: 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

示例7: SqlDataReader2Json

        public static JArray SqlDataReader2Json(SqlDataReader reader, string col0, string col1)
        {
            var colNames = new Dictionary<string, int>();
            for (int i = 0; i < reader.FieldCount; i++)
            {
                colNames[reader.GetName(i)] = i;
            }

            var parent = new Dictionary<string, HashSet<string>>(StringComparer.OrdinalIgnoreCase);

            while (reader.Read())
            {
                string parentColumn = reader.GetString(colNames[col0]);
                string childColumn = reader.GetString(colNames[col1]);

                HashSet<string> child;
                if (!parent.TryGetValue(parentColumn, out child))
                {
                    child = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
                    parent.Add(parentColumn, child);
                }

                child.Add(childColumn);
            }

            return MakeJArray(parent);
        }
开发者ID:joyhui,项目名称:NuGet.Jobs,代码行数:27,代码来源:JobHelper.cs

示例8: MakeViewLDV

        /// <summary>
        /// Creates a new instance of the ViewLDV class and populates it with data from the specified SqlDataReader.
        /// </summary>
        private static ViewLDVInfo MakeViewLDV(SqlDataReader dataReader)
        {
            ViewLDVInfo viewLDV = new ViewLDVInfo();

            if (dataReader.IsDBNull(Cod_LDV) == false)
                viewLDV.Cod_LDV = dataReader.GetInt32(Cod_LDV);
            if (dataReader.IsDBNull(Cod_TipoLDV) == false)
                viewLDV.Cod_TipoLDV = dataReader.GetInt32(Cod_TipoLDV);
            if (dataReader.IsDBNull(Tipo_LDV) == false)
                viewLDV.Tipo_LDV = dataReader.GetString(Tipo_LDV);
            if (dataReader.IsDBNull(Nombre_Lugar) == false)
                viewLDV.Nombre_Lugar = dataReader.GetString(Nombre_Lugar);
            if (dataReader.IsDBNull(Cod_Direccion) == false)
                viewLDV.Cod_Direccion = dataReader.GetInt32(Cod_Direccion);
            if (dataReader.IsDBNull(Calle) == false)
                viewLDV.Calle = dataReader.GetString(Calle);
            if (dataReader.IsDBNull(Cod_Localidad) == false)
                viewLDV.Cod_Localidad = dataReader.GetInt32(Cod_Localidad);
            if (dataReader.IsDBNull(Localidad) == false)
                viewLDV.Localidad = dataReader.GetString(Localidad);
            if (dataReader.IsDBNull(Cod_Provincia) == false)
                viewLDV.Cod_Provincia = dataReader.GetInt32(Cod_Provincia);
            if (dataReader.IsDBNull(Provincia) == false)
                viewLDV.Provincia = dataReader.GetString(Provincia);

            return viewLDV;
        }
开发者ID:Avaruz,项目名称:Artemisa,代码行数:30,代码来源:ViewLDVDb.cs

示例9: Project

        public Project(string name, string description, string businessvalue)
        {
            mName = name;
            mDescription = description;
            mBusinessValue = businessvalue;

            mDatabase.connect();

            mReader=mDatabase.executeread("SELECT Description FROM [dbo].[Issues] WHERE ProjectName='" + mName + "'");
            while (mReader.Read() )
            {
                mIssues.Add(new Issue(mReader.GetString(0).ToString(), mName));
            }
            mReader.Close();

            mReader = mDatabase.executeread("SELECT Description, Address FROM [dbo].[Link] WHERE ProjectName='" + mName + "'");
            while (mReader.Read() )
            {
                mLinks.Add(new Link(mReader.GetString(0).ToString(), mName, mReader.GetString(1).ToString()));
            }
            mReader.Close();

            mReader = mDatabase.executeread("SELECT DependantName, [dbo].[Project].Description, [dbo].[Project].BusinessValueName FROM [dbo].[Dependents], [dbo].[Project] WHERE ProjectName='" + mName + "' AND DependantName=Name");
            while (mReader.Read() )
            {
                mDependencies.Add(new Project(mReader.GetString(0).ToString(), mReader.GetString(1).ToString(), mReader.GetString(2).ToString()));
            }
            mReader.Close();
        }
开发者ID:grovecha,项目名称:RocketRoadmap,代码行数:29,代码来源:Project.cs

示例10: 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

示例11: ProcessSqlResult

 protected override Exception ProcessSqlResult(SqlDataReader reader)
 {
     Exception nextResultSet = StoreUtilities.GetNextResultSet(base.InstancePersistenceCommand.Name, reader);
     if (nextResultSet == null)
     {
         reader.NextResult();
         List<IDictionary<XName, object>> parameters = new List<IDictionary<XName, object>>();
         if (reader.Read())
         {
             do
             {
                 IDictionary<XName, object> item = new Dictionary<XName, object>();
                 item.Add(WorkflowServiceNamespace.SiteName, reader.GetString(0));
                 item.Add(WorkflowServiceNamespace.RelativeApplicationPath, reader.GetString(1));
                 item.Add(WorkflowServiceNamespace.RelativeServicePath, reader.GetString(2));
                 parameters.Add(item);
             }
             while (reader.Read());
         }
         else
         {
             base.Store.UpdateEventStatus(false, InstancePersistenceEvent<HasActivatableWorkflowEvent>.Value);
             base.StoreLock.InstanceDetectionTask.ResetTimer(false);
         }
         base.InstancePersistenceContext.QueriedInstanceStore(new ActivatableWorkflowsQueryResult(parameters));
     }
     return nextResultSet;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:28,代码来源:QueryActivatableWorkflowAsyncResult.cs

示例12: MakeViewAuditoriaListaVerificacionDetalle

        /// <summary>
        /// Creates a new instance of the ViewAuditoriaListaVerificacionDetalle class and populates it with data from the specified SqlDataReader.
        /// </summary>
        private static ViewAuditoriaListaVerificacionDetalleInfo MakeViewAuditoriaListaVerificacionDetalle(SqlDataReader dataReader)
        {
            ViewAuditoriaListaVerificacionDetalleInfo viewAuditoriaListaVerificacionDetalle = new ViewAuditoriaListaVerificacionDetalleInfo();

            if (dataReader.IsDBNull(AuditoriaListaVerificacionDetalleId) == false)
                viewAuditoriaListaVerificacionDetalle.AuditoriaListaVerificacionDetalleId = dataReader.GetInt32(AuditoriaListaVerificacionDetalleId);
            if (dataReader.IsDBNull(AuditoriaListaVerificacionId) == false)
                viewAuditoriaListaVerificacionDetalle.AuditoriaListaVerificacionId = dataReader.GetInt32(AuditoriaListaVerificacionId);
            if (dataReader.IsDBNull(AuditoriaPuntoId) == false)
                viewAuditoriaListaVerificacionDetalle.AuditoriaPuntoId = dataReader.GetInt32(AuditoriaPuntoId);
            if (dataReader.IsDBNull(AuditoriaControlId) == false)
                viewAuditoriaListaVerificacionDetalle.AuditoriaControlId = dataReader.GetInt32(AuditoriaControlId);
            if (dataReader.IsDBNull(PuntajeRequerido) == false)
                viewAuditoriaListaVerificacionDetalle.PuntajeRequerido = dataReader.GetDecimal(PuntajeRequerido);
            if (dataReader.IsDBNull(AuditoriaPunto) == false)
                viewAuditoriaListaVerificacionDetalle.AuditoriaPunto = dataReader.GetString(AuditoriaPunto);
            if (dataReader.IsDBNull(AuditoriaControl) == false)
                viewAuditoriaListaVerificacionDetalle.AuditoriaControl = dataReader.GetString(AuditoriaControl);
            if (dataReader.IsDBNull(Orden) == false)
                viewAuditoriaListaVerificacionDetalle.Orden = dataReader.GetByte(Orden);
            if (dataReader.IsDBNull(Activo) == false)
                viewAuditoriaListaVerificacionDetalle.Activo = dataReader.GetBoolean(Activo);

            return viewAuditoriaListaVerificacionDetalle;
        }
开发者ID:Avaruz,项目名称:SGC,代码行数:28,代码来源:ViewAuditoriaListaVerificacionDetalleDb.cs

示例13: AuthTest

        public bool AuthTest(string username, string password, ref userType theUser)
        {
            bool autorised = false;
            OpenConnection();
            Console.WriteLine("Debugging:");
            soHigh(username, ref password);

            sqlCmd.CommandText = string.Format("select StaffName, Password, StaffTypeID, StaffID from Staff WHERE StaffName='{0}' AND Password='{1}';", username, password);
            sqlCmd.Connection = dbConnection;
            reader = sqlCmd.ExecuteReader();
            if (reader.HasRows) {
                reader.Read();
                if ((username == reader.GetString(0)) && (password == reader.GetString(1))) {
                    userid = reader.GetInt32(3);
                    theUser = (userType)reader.GetInt32(2);
                    autorised = true;

                }
            }
            if(debugging){
            AuthDebugging(username, password);
            }

            CloseConnection();

            return autorised;
        }
开发者ID:JosephSalmond,项目名称:INB201,代码行数:27,代码来源:MiddleWare.cs

示例14: LoginDB

        public LoginDB(System.Data.SqlClient.SqlDataReader reader)
        {
            this.reader = reader;
            this.ID = reader.GetInt64(reader.GetOrdinal("Id"));
            this.Login = reader.GetString(reader.GetOrdinal("Login"));
            this.Senha = reader.GetString(reader.GetOrdinal("Senha"));

        }
开发者ID:rogeriofabricio,项目名称:XamarinCursoCross,代码行数:8,代码来源:Login.cs

示例15: SqlLocation

 /// <summary>
 /// Constructs an instance of IStoreLocation using parts of a row from SqlDataReader.
 /// Used for creating the shard location instance.
 /// </summary>
 /// <param name="reader">SqlDataReader whose row has shard information.</param>
 /// <param name="offset">Reader offset for column that begins shard information.</param>
 internal SqlLocation(SqlDataReader reader, int offset)
 {
     this.Location = new ShardLocation(
         reader.GetString(offset + 1),
         reader.GetString(offset + 3),
         (SqlProtocol)reader.GetInt32(offset),
         reader.GetInt32(offset + 2));
 }
开发者ID:CrossPoint,项目名称:elastic-db-tools,代码行数:14,代码来源:SqlLocation.cs


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