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


C# SqlClient.SqlDataReader类代码示例

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


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

示例1: convert

        public List<List<String>> convert(SqlDataReader reader)
        {
            if (reader != null)
            {
                List<List<String>> list = new List<List<String>>();

                while (reader.Read())
                {
                    List<String> tmp = new List<String>();
                    for (int i = 0; i < reader.FieldCount; i++)
                    {
                        string s = "";
                        try
                        {
                            s = reader.GetString(i);
                        }
                        catch (SqlNullValueException)
                        {
                            s = "null";
                        }

                        tmp.Add(s);

                    }
                    list.Add(tmp);
                }
                return list;
            }
            return null;
        }
开发者ID:submarines-and,项目名称:TacoHacker999,代码行数:30,代码来源:sqlCronus.cs

示例2: Read

    public static PMSAgency Read(SqlDataReader reader)
    {
        PMSAgency retval = new PMSAgency();

        for (int i = 0; i < reader.FieldCount; i++)
        {
            switch (reader.GetName(i))
            {
                case "GroupSegment":
                    retval.Segment = Helper.ToString(reader[i]);
                    break;
                case "AType":
                    retval.ActionType = Helper.ToString(reader[i]);
                    break;
                case "Agency":
                    retval.AgencyName = Helper.ToString(reader[i]);
                    break;
                case "Market":
                    retval.Market = Helper.ToString(reader[i]);
                    break;
                case "RepGroup":
                    retval.RepGroup = Helper.ToString(reader[i]);
                    break;
               case "SiteID":
                    retval.SiteID = Helper.ToInt32(reader[i]);
                    break;
            }
        }
        return retval;
    }
开发者ID:darinel,项目名称:PSInterProdOldVersion,代码行数:30,代码来源:PMSAgencyDB.cs

示例3: SafeGetString

 /** Descripcion:
  *
  * REQ: SqlDataReader, int
  *
  * RET: static string
  */
 public static string SafeGetString(SqlDataReader reader, int colIndex)
 {
     if (!reader.IsDBNull(colIndex))
         return reader.GetString(colIndex);
     else
         return string.Empty;
 }
开发者ID:ProyInge,项目名称:ProyectoInge,代码行数:13,代码来源:ControladoraBDProyecto.cs

示例4: HashSum

 public HashSum(SqlDataReader reader, String secret = "PZS")
 {
     DataTable dt = new DataTable();
     dt.Load(reader);
     dt.TableName = secret;
     this.dt = dt;
 }
开发者ID:DrBrown3,项目名称:SQL_Exec,代码行数:7,代码来源:HashSum.cs

示例5: CloseCommand

 public bool CloseCommand()
 {
     bool flag = true;
     try
     {
         if (connection != null)
         {
             if (sqlReader != null)
             {
                 sqlReader.Close();
                 sqlReader.Dispose();
                 sqlReader = (SqlDataReader)null;
             }
             if (sqlCommand != null)
             {
                 sqlCommand.Dispose();
                 sqlCommand = (SqlCommand)null;
             }
         }
     }
     catch (Exception ex)
     {
         flag = false;
         hasError = true;
         errorMessage = "Database command error : " + ex.Message;
     }
     return flag;
 }
开发者ID:GlxSeg,项目名称:SEGClone,代码行数:28,代码来源:SqlHelper.cs

示例6: SqlCachedBuffer

 internal SqlCachedBuffer(SqlDataReader dataRdr, int columnOrdinal, long startPosition)
 {
     int num;
     this._cachedBytes = new ArrayList();
     long dataIndex = startPosition;
     do
     {
         byte[] buffer = new byte[0x800];
         num = (int) dataRdr.GetBytesInternal(columnOrdinal, dataIndex, buffer, 0, 0x800);
         dataIndex += num;
         if (this._cachedBytes.Count == 0)
         {
             this.AddByteOrderMark(buffer, num);
         }
         if (0 < num)
         {
             if (num < buffer.Length)
             {
                 byte[] dst = new byte[num];
                 Buffer.BlockCopy(buffer, 0, dst, 0, num);
                 buffer = dst;
             }
             this._cachedBytes.Add(buffer);
         }
     }
     while (0 < num);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:27,代码来源:SqlCachedBuffer.cs

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

示例8: ChiTietPhieuXuatKho

 public ChiTietPhieuXuatKho(SqlDataReader dataReader)
 {
     PhieuXuatKhoGuid = dataReader["PhieuXuatKhoGuid"] != null ? (Guid)dataReader["PhieuXuatKhoGuid"] : Guid.Empty;
     ItemStoreGuid = dataReader["ItemStoreGuid"] != null ? (Guid)dataReader["ItemStoreGuid"] : Guid.Empty;
     HoaDonBanHangGuid = dataReader["HoaDonBanHangGuid"] != null ? (Guid)dataReader["HoaDonBanHangGuid"] : Guid.Empty;
     SoLuong = dataReader["SoLuong"] != null ? (Int32)dataReader["SoLuong"] : 0;
 }
开发者ID:enjoyvinh,项目名称:project-hutech,代码行数:7,代码来源:ChiTietPhieuXuatKho.cs

示例9: MakeViewAuditoriaListaVerificacionDetalleCross

        /// <summary>
        /// Creates a new instance of the ViewAuditoriaListaVerificacionDetalleCross class and populates it with data from the specified SqlDataReader.
        /// </summary>
        private static ViewAuditoriaListaVerificacionDetalleCrossInfo MakeViewAuditoriaListaVerificacionDetalleCross(SqlDataReader dataReader)
        {
            ViewAuditoriaListaVerificacionDetalleCrossInfo viewAuditoriaListaVerificacionDetalleCross = new ViewAuditoriaListaVerificacionDetalleCrossInfo();

            if (dataReader.IsDBNull(AuditoriaListaVerificacionDetalleCargoId) == false)
                viewAuditoriaListaVerificacionDetalleCross.AuditoriaListaVerificacionDetalleCargoId = dataReader.GetInt32(AuditoriaListaVerificacionDetalleCargoId);
            if (dataReader.IsDBNull(AuditoriaListaVerificacionDetalleId) == false)
                viewAuditoriaListaVerificacionDetalleCross.AuditoriaListaVerificacionDetalleId = dataReader.GetInt32(AuditoriaListaVerificacionDetalleId);
            if (dataReader.IsDBNull(AuditoriaListaVerificacionId) == false)
                viewAuditoriaListaVerificacionDetalleCross.AuditoriaListaVerificacionId = dataReader.GetInt32(AuditoriaListaVerificacionId);
            if (dataReader.IsDBNull(CargoId) == false)
                viewAuditoriaListaVerificacionDetalleCross.CargoId = dataReader.GetInt32(CargoId);
            if (dataReader.IsDBNull(Cargo) == false)
                viewAuditoriaListaVerificacionDetalleCross.Cargo = dataReader.GetString(Cargo);
            if (dataReader.IsDBNull(Activo) == false)
                viewAuditoriaListaVerificacionDetalleCross.Activo = dataReader.GetBoolean(Activo);
            if (dataReader.IsDBNull(AuditoriaPunto) == false)
                viewAuditoriaListaVerificacionDetalleCross.AuditoriaPunto = dataReader.GetString(AuditoriaPunto);
            if (dataReader.IsDBNull(AuditoriaControl) == false)
                viewAuditoriaListaVerificacionDetalleCross.AuditoriaControl = dataReader.GetString(AuditoriaControl);
            if (dataReader.IsDBNull(PuntajeRequerido) == false)
                viewAuditoriaListaVerificacionDetalleCross.PuntajeRequerido = dataReader.GetDecimal(PuntajeRequerido);
            if (dataReader.IsDBNull(Empresa) == false)
                viewAuditoriaListaVerificacionDetalleCross.Empresa = dataReader.GetString(Empresa);
            if (dataReader.IsDBNull(Orden) == false)
                viewAuditoriaListaVerificacionDetalleCross.Orden = dataReader.GetByte(Orden);

            return viewAuditoriaListaVerificacionDetalleCross;
        }
开发者ID:Avaruz,项目名称:SGC,代码行数:32,代码来源:ViewAuditoriaListaVerificacionDetalleCrossDb.cs

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

示例11: GetTemplate

        public Template GetTemplate(SqlDataReader reader)
        {
            var htmlTemplate = reader["Template"].ToString();
            var name = reader["Name"].ToString();

            return new Template(name, htmlTemplate);
        }
开发者ID:Confirmit,项目名称:Students,代码行数:7,代码来源:TemplateProvider.cs

示例12: CustomTheme

    } // End of the constructor

    /// <summary>
    /// Create a new custom theme from a reader
    /// </summary>
    /// <param name="reader"></param>
    public CustomTheme(SqlDataReader reader)
    {
        // Set values for instance variables
        this.id = Convert.ToInt32(reader["id"]);
        this.name = reader["name"].ToString();

    } // End of the constructor
开发者ID:raphaelivo,项目名称:a-webshop,代码行数:13,代码来源:CustomTheme.cs

示例13: readTable

        public static List<Club> readTable(string SqlQuery, string serverName, string databaseName)
        {
            myConnection = new SqlConnection(serverName + ";" + databaseName + ";" + "Integrated Security=true");

            try
            {
                myConnection.Open();
                myCommand = new SqlCommand(SqlQuery, myConnection);
                myReader = myCommand.ExecuteReader();
                ClubList.Clear();
                while(myReader.Read()) {
                    //Console.WriteLine(myReader[0].ToString());
                    //code here to map query output to club objects and put into list
                    ClubList.Add(new Club
                    {
                        id = myReader[0].ToString(),
                        //name = myReader[1].ToString(),
                        //address = myReader[2].ToString(),
                        //city = myReader[3].ToString(),
                        //state = myReader[4].ToString()
                    });
                }
            } catch (Exception e) {
                Console.WriteLine(e.ToString());
            }
            finally
            {
                myConnection.Close();
            }
            return ClubList;
        }
开发者ID:mashhype,项目名称:APIParsers,代码行数:31,代码来源:DBMethods.cs

示例14: loadlist

        // Apresentar os registros da pesquisa desejada.
        public void loadlist()
        {
            listBox1.Items.Clear();
            listBox2.Items.Clear();
            listBox3.Items.Clear();
            listBox4.Items.Clear();
            listBox5.Items.Clear();
            listBox6.Items.Clear();
            listBox7.Items.Clear();

            conexao.Open();
            comando.CommandText = "SELECT * FROM Contatos";
            LerDados = comando.ExecuteReader();
            if (LerDados.HasRows)
            {
                while (LerDados.Read())
                {
                    listBox1.Items.Add(LerDados[0].ToString());
                    listBox2.Items.Add(LerDados[1].ToString());
                    listBox3.Items.Add(LerDados[2].ToString());
                    listBox4.Items.Add(LerDados[3].ToString());
                    listBox5.Items.Add(LerDados[4].ToString());
                    listBox6.Items.Add(LerDados[5].ToString());
                    listBox7.Items.Add(LerDados[6].ToString());

                }
            }
            conexao.Close();
        }
开发者ID:LuizGiovaniJoao,项目名称:AgendaEletronica1.0,代码行数:30,代码来源:Pesquisa.cs

示例15: cbo

        private void cbo()
        {
            sb = new StringBuilder();
            sb.Remove(0, sb.Length);
            sb.Append("SELECT SupplierId,SupplierName FROM SUPPLIER;");
            sb.Append("SELECT UserId,UserName FROM UserLogin;");

            string sqlIni = sb.ToString();
            com = new SqlCommand();
            com.CommandText = sqlIni;
            com.CommandType = CommandType.Text;
            com.Connection = Conn;
            dr = com.ExecuteReader();

            if (dr.HasRows)
            {
                //supplier
                DataTable dtSupplier = new DataTable();
                dtSupplier.Load(dr);
                cboSupplier.BeginUpdate();
                cboSupplier.DisplayMember = "SupplierName";
                cboSupplier.ValueMember = "SupplierId";
                cboSupplier.DataSource = dtSupplier;
                cboSupplier.EndUpdate();
                //User
                DataTable dtUserId = new DataTable();
                dtUserId.Load(dr);
                cboUserId.BeginUpdate();
                cboUserId.DisplayMember = "UserName";
                cboUserId.ValueMember = "UserId";
                cboUserId.DataSource = dtUserId;
                cboUserId.EndUpdate();

            }
        }
开发者ID:itktc,项目名称:projectktc-v2,代码行数:35,代码来源:frmUpdateBidCancle.cs


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